config

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2021 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"`
	PluginFilePath string         `json:"pluginFilePath" yaml:"pluginFilePath"`
	PluginsGroup   []PluginsGroup `json:"pluginsGroup" yaml:"pluginsGroup"`
}

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 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"`
	ToParamTypes    []string `yaml:"toParamTypes" json:"toParamTypes"`
	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

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

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 Plugin

type Plugin struct {
	Name               string `json:"name" yaml:"name"`
	Version            string `json:"version" yaml:"version"`
	Priority           int    `json:"priority" yaml:"priority"`
	ExternalLookupName string `json:"externalLookupName" yaml:"externalLookupName"`
}

type PluginsConfig

type PluginsConfig struct {
	PrePlugins  PluginsInUse `json:"pre" yaml:"pre"`
	PostPlugins PluginsInUse `json:"post" yaml:"post"`
}

PluginsConfig defines the pre & post plugins

type PluginsGroup

type PluginsGroup struct {
	GroupName string   `json:"groupName" yaml:"groupName"`
	Plugins   []Plugin `json:"plugins" yaml:"plugins"`
}

PluginsGroup defines the plugins group info

type PluginsInUse

type PluginsInUse struct {
	GroupNames  []string `json:"groupNames" yaml:"groupNames"`
	PluginNames []string `json:"pluginNames" yaml:"pluginNames"`
}

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"`
	Plugins     PluginsConfig     `json:"plugins" yaml:"plugins"`
	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

Jump to

Keyboard shortcuts

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