Documentation ¶
Index ¶
- Variables
- func GetMiddleware(name string) (middleware gin.HandlersChain, err error)
- func ParseConfig(config EngineConfig) (engine *http.Engine, err error)
- func ParseRouter(config RouterConfig) (group *http.EndpointGroup, err error)
- func RegisterArrangedChain[request, response any](name string, fns ...http.Handler[request, response])
- func RegisterEndPoint[request, response any](name string, allocRequest request, allocResponse response)
- func RegisterMiddleware(name string, middleware gin.HandlersChain)
- func RegisterPriorityArrangedChain[request, response any](name string, priority int, fns ...http.Handler[request, response])
- type Arranged
- type ArrangedChain
- func GetArrangedChain[request, response any](name string, req request, res response) (chain ArrangedChain[request, response], err error)
- func NewArrangedChain[request, response any](name string, chain http.Chain[request, response]) ArrangedChain[request, response]
- func NewArrangedChainWithPriority[request, response any](name string, priority int, chain http.Chain[request, response]) ArrangedChain[request, response]
- type ArrangedEndPoint
- type EndPointConfig
- type EngineConfig
- type ParamsConfig
- type RouterConfig
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrEndpointNotFound = errors.New("endpoint not found") ErrChainNotFound = errors.New("chain not found") ErrTypeNotMatched = errors.New("type not matched") ErrEmptyChain = errors.New("empty chain") ErrMiddlewareNotFound = errors.New("middleware not found") // PriorityDefault is the default priority for chains, which is the lowest priority PriorityDefault = -1 // PriorityLow is the second-lowest priority PriorityLow = 0 // PriorityNormal is the normal priority PriorityNormal = 1 << 16 // PriorityHigh is the second-highest priority PriorityHigh = 1 << 32 // PriorityEmergency is the highest priority PriorityEmergency = 1 << 48 )
Functions ¶
func GetMiddleware ¶
func GetMiddleware(name string) (middleware gin.HandlersChain, err error)
func ParseConfig ¶
func ParseConfig(config EngineConfig) (engine *http.Engine, err error)
func ParseRouter ¶
func ParseRouter(config RouterConfig) (group *http.EndpointGroup, err error)
func RegisterArrangedChain ¶
func RegisterEndPoint ¶
func RegisterMiddleware ¶
func RegisterMiddleware(name string, middleware gin.HandlersChain)
Types ¶
type ArrangedChain ¶
type ArrangedChain[request, response any] interface { Arranged Chain() http.Chain[request, response] Request() request Response() response }
func GetArrangedChain ¶
func GetArrangedChain[request, response any](name string, req request, res response) (chain ArrangedChain[request, response], err error)
func NewArrangedChain ¶
func NewArrangedChain[request, response any](name string, chain http.Chain[request, response]) ArrangedChain[request, response]
type ArrangedEndPoint ¶
type ArrangedEndPoint interface { UniqueName() string ParseConfig(opts EndPointConfig) (endpoint http.EndPointInterface, err error) }
func GetEndPoint ¶
func GetEndPoint(name string) (endpoint ArrangedEndPoint, err error)
type EndPointConfig ¶
type EndPointConfig struct { Name string `json:"name" yaml:"name"` Path string `json:"path" yaml:"path"` Methods []string `json:"methods" yaml:"methods"` Chains []string `json:"chains" yaml:"chains"` Middlewares []string `json:"middlewares,omitempty" yaml:"middlewares,omitempty"` Headers ParamsConfig `json:"headers,omitempty" yaml:"headers,omitempty"` Paths ParamsConfig `json:"paths,omitempty" yaml:"paths,omitempty"` Queries ParamsConfig `json:"queries,omitempty" yaml:"queries,omitempty"` Cookies ParamsConfig `json:"cookies,omitempty" yaml:"cookies,omitempty"` }
type EngineConfig ¶
type EngineConfig struct { Bind string `json:"bind" yaml:"bind" xml:"bind"` Router RouterConfig `json:"router" yaml:"router" xml:"router"` Serving bool `json:"serving" yaml:"serving" xml:"serving"` Path string `json:"path,omitempty" yaml:"path,omitempty" xml:"path,omitempty"` Block bool `json:"block,omitempty" yaml:"block,omitempty" xml:"block,omitempty"` }
type ParamsConfig ¶
type RouterConfig ¶
type RouterConfig struct { Path string `json:"path" yaml:"path" xml:"path"` SubRouters []RouterConfig `json:"sub_routers,omitempty" yaml:"sub_routers,omitempty" xml:"sub_routers,omitempty"` EndPoints []EndPointConfig `json:"endpoints,omitempty" yaml:"endpoints,omitempty" xml:"endpoints,omitempty"` }
Click to show internal directories.
Click to hide internal directories.