server

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2022 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MethodPost = "POST"
	MethodGet  = "GET"
)
View Source
const (
	StatusStart = "start"
	StatusStop  = "stop"
)
View Source
const SupportPackageIsVersion1 = true

SupportPackageIsVersion1 These constants should not be referenced from any other code.

Variables

This section is empty.

Functions

func CodecForRequest

func CodecForRequest(ctx context.Context, name string) (encoding.Codec, bool)

CodecForRequest get encoding.Codec via http.Request

func DefaultErrorEncoder

func DefaultErrorEncoder(ctx context.Context, err error)

DefaultErrorEncoder encodes the error to the HTTP response.

func DefaultRequestDecoder

func DefaultRequestDecoder(ctx context.Context, v interface{}) error

DefaultRequestDecoder decodes the request body to object.

func DefaultResponseEncoder

func DefaultResponseEncoder(ctx context.Context, v interface{}) error

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

type AlloterContext struct {
	Actx *alloter.Context
	// contains filtered or unexported fields
}

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

type AlloterEngine struct {
	Engine *alloter.Engine
	// contains filtered or unexported fields
}

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

type DecodeRequestFunc func(context.Context, interface{}) error

DecodeRequestFunc is decode request func.

type EncodeErrorFunc

type EncodeErrorFunc func(context.Context, error)

EncodeErrorFunc is encode error func.

type EncodeResponseFunc

type EncodeResponseFunc func(context.Context, interface{}) error

EncodeResponseFunc is encode response func.

type GinContext

type GinContext struct {
	Gctx *gin.Context
	// contains filtered or unexported fields
}

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 GinEngine struct {
	Engine *gin.Engine
	// contains filtered or unexported fields
}

func NewGinEngine

func NewGinEngine(engine *gin.Engine, opts ...Option) *GinEngine

func (*GinEngine) Handle

func (e *GinEngine) Handle(method string, path string, callfunc HandlerFunc)

func (*GinEngine) NoMethod

func (e *GinEngine) NoMethod()

func (*GinEngine) NoRoute

func (e *GinEngine) NoRoute()

func (*GinEngine) Write

func (e *GinEngine) Write(ctx context.Context, resp interface{})

type HandlerFunc

type HandlerFunc func(context.Context)
type Header xtypes.SMap

type Hook

type Hook func(ctx context.Context) error

type IChecker

type IChecker interface {
	Check() error
}

type Method

type Method string

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 WithSrvName(name string) Option

func WithSrvType

func WithSrvType(srvType string) Option

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.

type RunStatus

type RunStatus uint
const (
	Unstarted RunStatus = 1
	Pause     RunStatus = 2
	Running   RunStatus = 4
	Pending   RunStatus = 8
	Stoped    RunStatus = 16
)

type Status

type Status string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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