Documentation ¶
Index ¶
- Constants
- func CodecForRequest(ctx context.Context, name string) (encoding.Codec, bool)
- func DefaultErrorEncoder(ctx context.Context, err error)
- func DefaultRequestDecoder(ctx context.Context, v interface{}) error
- func DefaultResponseEncoder(ctx context.Context, v interface{}) error
- func RegistryEngineRoute(engine AdapterEngine, router *RouterGroup)
- type AdapterEngine
- type AlloterContext
- func (ctx *AlloterContext) Bind(obj interface{}) error
- func (ctx *AlloterContext) Close()
- func (ctx *AlloterContext) Context() context.Context
- func (ctx *AlloterContext) GetImpl() interface{}
- func (ctx *AlloterContext) Header(key string) string
- func (ctx *AlloterContext) Log() log.Logger
- func (ctx *AlloterContext) Meta() map[string]interface{}
- func (ctx *AlloterContext) Request() vctx.Request
- func (ctx *AlloterContext) ResetContext(nctx context.Context)
- func (ctx *AlloterContext) Response() vctx.Response
- func (ctx *AlloterContext) ServerName() string
- func (ctx *AlloterContext) ServerType() string
- type AlloterEngine
- type DecodeRequestFunc
- type EncodeErrorFunc
- type EncodeResponseFunc
- type GinContext
- func (ctx *GinContext) Bind(obj interface{}) error
- func (ctx *GinContext) Close()
- func (ctx *GinContext) Context() context.Context
- func (ctx *GinContext) GetImpl() interface{}
- func (ctx *GinContext) Header(key string) string
- func (ctx *GinContext) Log() log.Logger
- func (ctx *GinContext) Meta() map[string]interface{}
- func (ctx *GinContext) Request() vctx.Request
- func (ctx *GinContext) ResetContext(nctx context.Context)
- func (ctx *GinContext) Response() vctx.Response
- func (ctx *GinContext) ServerName() string
- func (ctx *GinContext) ServerType() string
- type GinEngine
- type HandlerFunc
- type Header
- type Hook
- type IChecker
- type Method
- type Option
- type RouterGroup
- func (group *RouterGroup) BasePath() string
- func (group *RouterGroup) Group(relativePath string, middlewares ...middleware.Middleware) *RouterGroup
- func (group *RouterGroup) Handle(relativePath string, handler interface{}, methods ...Method)
- func (group *RouterGroup) Use(middlewares ...middleware.Middleware) *RouterGroup
- type RunStatus
- type Status
Constants ¶
const ( MethodPost = "POST" MethodGet = "GET" )
const ( StatusStart = "start" StatusStop = "stop" )
const SupportPackageIsVersion1 = true
SupportPackageIsVersion1 These constants should not be referenced from any other code.
Variables ¶
This section is empty.
Functions ¶
func CodecForRequest ¶
CodecForRequest get encoding.Codec via http.Request
func DefaultErrorEncoder ¶
DefaultErrorEncoder encodes the error to the HTTP response.
func DefaultRequestDecoder ¶
DefaultRequestDecoder decodes the request body to object.
func DefaultResponseEncoder ¶
DefaultResponseEncoder encodes the object to the HTTP response.
func RegistryEngineRoute ¶
func RegistryEngineRoute(engine AdapterEngine, router *RouterGroup)
Types ¶
type AdapterEngine ¶
type AdapterEngine interface { NoMethod() NoRoute() Handle(method string, path string, callfunc HandlerFunc) Write(ctx context.Context, resp interface{}) }
type AlloterContext ¶
func (*AlloterContext) Bind ¶
func (ctx *AlloterContext) Bind(obj interface{}) error
func (*AlloterContext) Close ¶
func (ctx *AlloterContext) Close()
func (*AlloterContext) Context ¶
func (ctx *AlloterContext) Context() context.Context
func (*AlloterContext) GetImpl ¶
func (ctx *AlloterContext) GetImpl() interface{}
func (*AlloterContext) Header ¶
func (ctx *AlloterContext) Header(key string) string
func (*AlloterContext) Log ¶
func (ctx *AlloterContext) Log() log.Logger
func (*AlloterContext) Meta ¶
func (ctx *AlloterContext) Meta() map[string]interface{}
func (*AlloterContext) Request ¶
func (ctx *AlloterContext) Request() vctx.Request
func (*AlloterContext) ResetContext ¶
func (ctx *AlloterContext) ResetContext(nctx context.Context)
func (*AlloterContext) Response ¶
func (ctx *AlloterContext) Response() vctx.Response
func (*AlloterContext) ServerName ¶
func (ctx *AlloterContext) ServerName() string
func (*AlloterContext) ServerType ¶
func (ctx *AlloterContext) ServerType() string
type AlloterEngine ¶
func NewAlloterEngine ¶
func NewAlloterEngine(engine *alloter.Engine, opts ...Option) *AlloterEngine
func (*AlloterEngine) Handle ¶
func (e *AlloterEngine) Handle(method string, path string, callfunc HandlerFunc)
func (*AlloterEngine) NoMethod ¶
func (e *AlloterEngine) NoMethod()
func (*AlloterEngine) NoRoute ¶
func (e *AlloterEngine) NoRoute()
func (*AlloterEngine) Write ¶
func (e *AlloterEngine) Write(ctx context.Context, resp interface{})
type DecodeRequestFunc ¶
DecodeRequestFunc is decode request func.
type EncodeErrorFunc ¶
EncodeErrorFunc is encode error func.
type EncodeResponseFunc ¶
EncodeResponseFunc is encode response func.
type GinContext ¶
func (*GinContext) Bind ¶
func (ctx *GinContext) Bind(obj interface{}) error
func (*GinContext) Close ¶
func (ctx *GinContext) Close()
func (*GinContext) Context ¶
func (ctx *GinContext) Context() context.Context
func (*GinContext) GetImpl ¶
func (ctx *GinContext) GetImpl() interface{}
func (*GinContext) Header ¶
func (ctx *GinContext) Header(key string) string
func (*GinContext) Log ¶
func (ctx *GinContext) Log() log.Logger
func (*GinContext) Meta ¶
func (ctx *GinContext) Meta() map[string]interface{}
func (*GinContext) Request ¶
func (ctx *GinContext) Request() vctx.Request
func (*GinContext) ResetContext ¶
func (ctx *GinContext) ResetContext(nctx context.Context)
func (*GinContext) Response ¶
func (ctx *GinContext) Response() vctx.Response
func (*GinContext) ServerName ¶
func (ctx *GinContext) ServerName() string
func (*GinContext) ServerType ¶
func (ctx *GinContext) ServerType() string
type GinEngine ¶
type HandlerFunc ¶
type Option ¶
type Option func(*options)
func WithErrorEncoder ¶
func WithErrorEncoder(errorEncoder EncodeErrorFunc) Option
func WithRequestDecoder ¶
func WithRequestDecoder(requestDecoder DecodeRequestFunc) Option
func WithResponseEncoder ¶
func WithResponseEncoder(responseEncoder EncodeResponseFunc) Option
func WithSrvName ¶
func WithSrvType ¶
type RouterGroup ¶
type RouterGroup struct { ServiceGroups map[string]*router.Group Children map[string]*RouterGroup // contains filtered or unexported fields }
func NewRouterGroup ¶
func NewRouterGroup(basePath string) *RouterGroup
func (*RouterGroup) BasePath ¶
func (group *RouterGroup) BasePath() string
BasePath returns the base path of router group. For example, if v := router.Group("/rest/n/v1/api"), v.BasePath() is "/rest/n/v1/api".
func (*RouterGroup) Group ¶
func (group *RouterGroup) Group(relativePath string, middlewares ...middleware.Middleware) *RouterGroup
Group creates a new router group. You should add all the routes that have common middlewares or the same path prefix. For example, all the routes that use a common middleware for authorization could be grouped.
func (*RouterGroup) Handle ¶
func (group *RouterGroup) Handle(relativePath string, handler interface{}, methods ...Method)
Handle registers a new request handle and middleware with the given path and method. The last handler should be the real handler, the other ones should be middleware that can and should be shared among different routes. See the example code in GitHub.
For GET, POST requests the respective shortcut functions can be used.
This function is intended for bulk loading and to allow the usage of less frequently used, non-standardized or custom methods (e.g. for internal communication with a proxy).
func (*RouterGroup) Use ¶
func (group *RouterGroup) Use(middlewares ...middleware.Middleware) *RouterGroup
Use adds middleware to the group, see example code in GitHub.