Documentation
¶
Index ¶
- func DefaultConfigLoad(path string) *model.Bootstrap
- func GetBootstrap() *model.Bootstrap
- func Load(path string) *model.Bootstrap
- func RegisterConfigLoadFunc(f ConfigLoadFunc)
- func YAMLConfigLoad(path string) *model.Bootstrap
- type APIConfig
- type BodyDefinition
- type ConfigLoadFunc
- type Definition
- type DubboBackendConfig
- type HTTPBackendConfig
- type HTTPVerb
- type InboundRequest
- type IntegrationRequest
- type MappingParam
- type Method
- type Opt
- type Params
- type RequestType
- type Resource
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultConfigLoad ¶
DefaultConfigLoad if not config, will load this
func GetBootstrap ¶
GetBootstrap get config global, need a better name
func RegisterConfigLoadFunc ¶
func RegisterConfigLoadFunc(f ConfigLoadFunc)
RegisterConfigLoadFunc can replace a new config load function instead of default
func YAMLConfigLoad ¶
YAMLConfigLoad config load yaml
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
func LoadAPIConfigFromFile ¶
LoadAPIConfigFromFile load the api config from file
type BodyDefinition ¶
type BodyDefinition struct {
DefinitionName string `json:"definitionName" yaml:"definitionName"`
}
BodyDefinition connects the request body to the definitions
type ConfigLoadFunc ¶
ConfigLoadFunc parse a input(usually file path) into a proxy 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"`
ParamTypes []string `yaml:"paramTypes" json:"paramTypes"`
Retries string `yaml:"retries" json:"retries,omitempty"`
}
DubboBackendConfig defines the basic dubbo backend 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 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 MappingParam ¶
type MappingParam struct {
Name string `json:"name,omitempty" yaml:"name"`
MapTo string `json:"mapTo,omitempty" yaml:"mapTo"`
// Opt some action.
Opt Opt `json:"opt,omitempty" yaml:"opt,omitempty"`
}
MappingParam defines the mapping rules of headers and queryStrings
type Method ¶
type Method struct {
OnAir bool `json:"onAir" yaml:"onAir"` // 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 []string `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 ¶
UnmarshalYAML method custom UnmarshalYAML
type Opt ¶
type Opt struct {
// Name match dubbo.DefaultMapOption key.
Name string `json:"name,omitempty" yaml:"name"`
// Open control opt create, only true will create a Opt.
Open bool `json:"open,omitempty" yaml:"open"`
// Usable setTarget condition, true can set, false not set.
Usable bool `json:"usable,omitempty" yaml:"usable"`
}
Opt option, action for compatibility.
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" )
type Resource ¶
type Resource struct {
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 []string `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 ¶
UnmarshalYAML Resource custom UnmarshalYAML