config

package
v0.1.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 24, 2022 License: Apache-2.0 Imports: 1 Imported by: 17

Documentation

Index

Constants

View Source
const DefaultTimeoutStr = "1s"

Variables

This section is empty.

Functions

This section is empty.

Types

type APIConfig

type APIConfig struct {
	Name        string       `json:"name" yaml:"name"`
	Description string       `json:"description" yaml:"description"`
	Resources   []Resource   `json:"resources" yaml:"resources"`
	Definitions []Definition `json:"definitions" yaml:"definitions"`
}

APIConfig defines the data structure of the api gateway configuration

type BodyDefinition

type BodyDefinition struct {
	DefinitionName string `json:"definitionName" yaml:"definitionName"`
}

BodyDefinition connects the request body to the definitions

type Cluster added in v0.1.5

type Cluster struct {
	Name    string `json:"name,omitempty" yaml:"name"`       // cluster name
	Type    string `json:"type,omitempty" yaml:"type"`       // cluster type
	Address string `json:"address,omitempty" yaml:"address"` // cluster address
	Port    int    `json:"port,omitempty" yaml:"port"`       // cluster port
	ID      int    `json:"id,omitempty" yaml:"id"`           // cluster id
}

Cluster defines the cluster config

type Definition

type Definition struct {
	Name   string `json:"name" yaml:"name"`
	Schema string `json:"schema" yaml:"schema"` // use json schema
}

Definition defines the complex json request body

type DubboBackendConfig

type DubboBackendConfig struct {
	ClusterName     string `yaml:"clusterName" json:"clusterName"`
	ApplicationName string `yaml:"applicationName" json:"applicationName"`
	Protocol        string `yaml:"protocol" json:"protocol,omitempty" default:"dubbo"`
	Group           string `yaml:"group" json:"group"`
	Version         string `yaml:"version" json:"version"`
	Interface       string `yaml:"interface" json:"interface"`
	Method          string `yaml:"method" json:"method"`
	Retries         string `yaml:"retries" json:"retries,omitempty"`
}

DubboBackendConfig defines the basic dubbo backend config

type Filter added in v0.1.4

type Filter struct {
	Name   string                 `json:"name,omitempty" yaml:"name,omitempty"`
	Config map[string]interface{} `json:"config,omitempty" yaml:"config,omitempty"`
}

Filter filter with config

type HTTPBackendConfig

type HTTPBackendConfig struct {
	URL string `yaml:"url" json:"url,omitempty"`
	// downstream host.
	Host string `yaml:"host" json:"host,omitempty"`
	// path to replace.
	Path string `yaml:"path" json:"path,omitempty"`
	// http protocol, http or https.
	Schema string `yaml:"schema" json:"scheme,omitempty"`
}

HTTPBackendConfig defines the basic dubbo backend config

type HTTPFilters added in v0.1.5

type HTTPFilters []struct {
	Name   string      `yaml:"name" json:"name"`
	Config interface{} `yaml:"config" json:"config"`
}

HTTPFilters defines the http filter

type HTTPVerb

type HTTPVerb string

HTTPVerb defines the restful api http verb

const (
	// MethodAny any method
	MethodAny HTTPVerb = "ANY"
	// MethodGet get
	MethodGet HTTPVerb = "GET"
	// MethodHead head
	MethodHead HTTPVerb = "HEAD"
	// MethodPost post
	MethodPost HTTPVerb = "POST"
	// MethodPut put
	MethodPut HTTPVerb = "PUT"
	// MethodPatch patch
	MethodPatch HTTPVerb = "PATCH" // RFC 5789
	// MethodDelete delete
	MethodDelete HTTPVerb = "DELETE"
	// MethodOptions options
	MethodOptions HTTPVerb = "OPTIONS"
)

type InboundRequest

type InboundRequest struct {
	RequestType  `json:"requestType" yaml:"requestType"` //http, TO-DO: dubbo
	Headers      []Params                                `json:"headers" yaml:"headers"`
	QueryStrings []Params                                `json:"queryStrings" yaml:"queryStrings"`
	RequestBody  []BodyDefinition                        `json:"requestBody" yaml:"requestBody"`
}

InboundRequest defines the details of the inbound

type IntegrationRequest

type IntegrationRequest struct {
	RequestType        `json:"requestType" yaml:"requestType"` // dubbo, TO-DO: http
	DubboBackendConfig `json:"dubboBackendConfig,inline,omitempty" yaml:"dubboBackendConfig,inline,omitempty"`
	HTTPBackendConfig  `json:"httpBackendConfig,inline,omitempty" yaml:"httpBackendConfig,inline,omitempty"`
	MappingParams      []MappingParam `json:"mappingParams,omitempty" yaml:"mappingParams,omitempty"`
}

IntegrationRequest defines the backend request format and target

type Listener added in v0.1.5

type Listener struct {
	Name    string `yaml:"name" json:"name"`
	Address struct {
		SocketAddress struct {
			Address string `yaml:"address" json:"address"`
			Port    int    `yaml:"port" json:"port"`
		} `yaml:"socket-address" json:"socket_address"`
		Name string `yaml:"name" json:"name"`
	} `yaml:"address" json:"address"`
	RouteConfig RouteConfig `yaml:"route_config" json:"route_config"`
	HTTPFilters HTTPFilters `yaml:"http_filters" json:"http_filters"`
}

Listener defines the listener config

type MappingParam

type MappingParam struct {
	Name    string `json:"name,omitempty" yaml:"name"`
	MapTo   string `json:"mapTo,omitempty" yaml:"mapTo"`
	MapType string `json:"mapType,omitempty" yaml:"mapType"`
}

MappingParam defines the mapping rules of headers and queryStrings

type Method

type Method struct {
	ID                 int           `json:"id,omitempty" yaml:"id,omitempty"`
	ResourcePath       string        `json:"resourcePath" yaml:"resourcePath"`
	Enable             bool          `json:"enable" yaml:"enable"` // true means the method is up and false means method is down
	Timeout            time.Duration `json:"timeout" yaml:"timeout"`
	Mock               bool          `json:"mock" yaml:"mock"`
	Filters            []Filter      `json:"filters" yaml:"filters"`
	HTTPVerb           `json:"httpVerb" yaml:"httpVerb"`
	InboundRequest     `json:"inboundRequest" yaml:"inboundRequest"`
	IntegrationRequest `json:"integrationRequest" yaml:"integrationRequest"`
}

Method defines the method of the api

func (*Method) UnmarshalYAML

func (m *Method) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML method custom UnmarshalYAML

type Params

type Params struct {
	Name     string `json:"name" yaml:"name"`
	Type     string `json:"type" yaml:"type"`
	Required bool   `json:"required" yaml:"required"`
}

Params defines the simple parameter definition

type RequestType

type RequestType string

RequestType describes the type of the request. could be DUBBO/HTTP and others that we might implement in the future

const (
	// DubboRequest represents the dubbo request
	DubboRequest RequestType = "dubbo"
	// HTTPRequest represents the http request
	HTTPRequest RequestType = "http"
	// GRPCRequest represents the grpc request
	GRPCRequest RequestType = "grpc"
)

type Resource

type Resource struct {
	ID          int               `json:"id,omitempty" yaml:"id,omitempty"`
	Type        string            `json:"type" yaml:"type"` // Restful, Dubbo
	Path        string            `json:"path" yaml:"path"`
	Timeout     time.Duration     `json:"timeout" yaml:"timeout"`
	Description string            `json:"description" yaml:"description"`
	Filters     []Filter          `json:"filters" yaml:"filters"`
	Methods     []Method          `json:"methods" yaml:"methods"`
	Resources   []Resource        `json:"resources,omitempty" yaml:"resources,omitempty"`
	Headers     map[string]string `json:"headers,omitempty" yaml:"headers,omitempty"`
}

Resource defines the API path

func (*Resource) UnmarshalYAML

func (r *Resource) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML Resource custom UnmarshalYAML

type RouteConfig added in v0.1.5

type RouteConfig struct {
	Routes []struct {
		Match struct {
			Prefix string `yaml:"prefix" json:"prefix"`
		} `yaml:"match" json:"match"`
		Route struct {
			Cluster                     string `yaml:"cluster" json:"cluster"`
			ClusterNotFoundResponseCode int    `yaml:"cluster_not_found_response_code" json:"cluster_not_found_response_code"`
		} `yaml:"route" json:"route"`
	} `yaml:"routes" json:"routes"`
}

RouteConfig defines the route config

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL