Documentation
¶
Index ¶
- func EmptyFormatter(*Context, int, Headers, interface{}) error
- func JSONFormatter(m *Context, code int, headers Headers, body interface{}) error
- func RpcFormatter(m *Context, code int, headers Headers, body interface{}) error
- func TextFormatter(m *Context, code int, headers Headers, body interface{}) error
- type CallFunc
- type ConfigItem
- type Context
- func (_ctx *Context) Decode(call func(http.Header, []byte) error) error
- func (_ctx *Context) Empty(code int) error
- func (_ctx *Context) Encode(call func() (int, Headers, interface{})) error
- func (_ctx *Context) Error(code int, err error) error
- func (_ctx *Context) GetCookies() map[string]*http.Cookie
- func (_ctx *Context) Redirect(url string) error
- func (_ctx *Context) SetCookie(key, value string, ttl time.Duration)
- type Debug
- type DebugConfig
- type FormatterFunc
- type HTTPConfig
- type Handler
- type Headers
- type ModuleInjecter
- type ResponseErrorModel
- type ResponseModel
- type Route
- type Router
- type RpcErrorBodyModel
- type RpcRequestModel
- type RpcResponseErrorModel
- type RpcResponseModel
- type Server
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func JSONFormatter ¶
func RpcFormatter ¶
Types ¶
type ConfigItem ¶
type Context ¶
type Context struct {
Writer http.ResponseWriter
Reader *http.Request
Formatter FormatterFunc
}
type Debug ¶
type Debug struct {
// contains filtered or unexported fields
}
func NewCustomDebug ¶
func NewCustomDebug(conf ConfigItem, log logger.Logger) *Debug
type DebugConfig ¶
type DebugConfig struct {
Debug ConfigItem `yaml:"debug" json:"debug"`
}
http server config
type FormatterFunc ¶
type HTTPConfig ¶
type HTTPConfig struct {
HTTP ConfigItem `yaml:"http" json:"http"`
}
type Handler ¶
type Handler struct {
Method string
Path string
Call CallFunc
Middleware CallFunc
Formatter FormatterFunc
}
type ModuleInjecter ¶
type ModuleInjecter interface {
Handlers() []Handler
}
type ResponseErrorModel ¶
type ResponseErrorModel struct {
Error string `json:"error"`
}
type Route ¶
type Route struct {
Call CallFunc
Middleware CallFunc
Formatter FormatterFunc
}
type Router ¶
func (*Router) InjectRoutes ¶
func (_rtr *Router) InjectRoutes(mod ModuleInjecter)
type RpcErrorBodyModel ¶
type RpcRequestModel ¶
type RpcRequestModel struct {
ID string `json:"id"`
Method string `json:"method"`
Params interface{} `json:"params,omitempty"`
}
json rpc model
type RpcResponseErrorModel ¶
type RpcResponseErrorModel struct {
ID string `json:"id"`
Error RpcErrorBodyModel `json:"error"`
}
type RpcResponseModel ¶
type RpcResponseModel struct {
ID string `json:"id"`
Result interface{} `json:"result"`
}
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func NewCustomServer ¶
func NewCustomServer(conf ConfigItem, log logger.Logger) *Server
Click to show internal directories.
Click to hide internal directories.