Documentation ¶
Index ¶
- func ErrorEncode(w http.ResponseWriter, obj error)
- func FormDataDecode(r *http.Request, obj interface{}) error
- func JSONDecode(r *http.Request, obj interface{}) error
- func JSONEncode(w http.ResponseWriter, obj interface{})
- func ParamFloat(r *http.Request, key string) (float64, error)
- func ParamInt(r *http.Request, key string) (int64, error)
- func ParamString(r *http.Request, key string) (string, error)
- func RawEncode(w http.ResponseWriter, obj []byte)
- func RecoveryMiddleware() ...
- func StreamEncode(w http.ResponseWriter, obj []byte, filename string)
- func WithClient() plugins.Plugin
- func WithServer() plugins.Plugin
- func XMLDecode(r *http.Request, obj interface{}) error
- func XMLEncode(w http.ResponseWriter, obj interface{})
- type BaseRouter
- func (v *BaseRouter) Global(middlewares ...)
- func (v *BaseRouter) Middlewares(path string, middlewares ...)
- func (v *BaseRouter) NoFoundHandler(call func(http.ResponseWriter, *http.Request))
- func (v *BaseRouter) Route(path string, ctrl func(http.ResponseWriter, *http.Request), methods ...string)
- func (v *BaseRouter) ServeHTTP(w http.ResponseWriter, r *http.Request)
- type ClientHttp
- type ClientHttpOption
- func ClientHttpOptionAuth(s signature.Storage) ClientHttpOption
- func ClientHttpOptionCodec(enc func(in interface{}) (body []byte, contentType string, err error), ...) ClientHttpOption
- func ClientHttpOptionCodecDefault() ClientHttpOption
- func ClientHttpOptionHeaders(keyVal ...string) ClientHttpOption
- func ClientHttpOptionSetup(proxy string, ttl time.Duration, countConn int) ClientHttpOption
- type ClientHttpPool
- type Config
- type ConfigHttpPool
- type Context
- type Cookie
- type ErrCtx
- type Header
- type Middleware
- type Param
- type RouteCollector
- type Router
- type RouterPool
- type Server
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ErrorEncode ¶
func ErrorEncode(w http.ResponseWriter, obj error)
func FormDataDecode ¶
func JSONDecode ¶
func JSONEncode ¶
func JSONEncode(w http.ResponseWriter, obj interface{})
func RawEncode ¶
func RawEncode(w http.ResponseWriter, obj []byte)
func RecoveryMiddleware ¶
func RecoveryMiddleware() func( func(http.ResponseWriter, *http.Request), ) func(http.ResponseWriter, *http.Request)
RecoveryMiddleware recovery go panic and write to log
func StreamEncode ¶
func StreamEncode(w http.ResponseWriter, obj []byte, filename string)
func WithServer ¶
WithServer launch of HTTP service with default Router
func XMLEncode ¶
func XMLEncode(w http.ResponseWriter, obj interface{})
Types ¶
type BaseRouter ¶
type BaseRouter struct {
// contains filtered or unexported fields
}
func NewBaseRouter ¶
func NewBaseRouter() *BaseRouter
func (*BaseRouter) Global ¶
func (v *BaseRouter) Global( middlewares ...func(func(http.ResponseWriter, *http.Request), ) func(http.ResponseWriter, *http.Request))
Global add global middlewares
func (*BaseRouter) Middlewares ¶
func (v *BaseRouter) Middlewares( path string, middlewares ...func(func(http.ResponseWriter, *http.Request), ) func(http.ResponseWriter, *http.Request))
Middlewares add middlewares to route
func (*BaseRouter) NoFoundHandler ¶
func (v *BaseRouter) NoFoundHandler(call func(http.ResponseWriter, *http.Request))
NoFoundHandler ctrlHandler call if route not found
func (*BaseRouter) Route ¶
func (v *BaseRouter) Route(path string, ctrl func(http.ResponseWriter, *http.Request), methods ...string)
Route add new route
func (*BaseRouter) ServeHTTP ¶
func (v *BaseRouter) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP http interface
type ClientHttp ¶
type ClientHttp struct {
// contains filtered or unexported fields
}
func NewClientHttp ¶
func NewClientHttp(opt ...ClientHttpOption) *ClientHttp
type ClientHttpOption ¶
type ClientHttpOption func(c *ClientHttp)
func ClientHttpOptionAuth ¶
func ClientHttpOptionAuth(s signature.Storage) ClientHttpOption
func ClientHttpOptionCodec ¶
func ClientHttpOptionCodecDefault ¶
func ClientHttpOptionCodecDefault() ClientHttpOption
func ClientHttpOptionHeaders ¶
func ClientHttpOptionHeaders(keyVal ...string) ClientHttpOption
func ClientHttpOptionSetup ¶
func ClientHttpOptionSetup(proxy string, ttl time.Duration, countConn int) ClientHttpOption
type ClientHttpPool ¶
type ClientHttpPool interface {
Create(opts ...ClientHttpOption) *ClientHttp
}
type Config ¶
type Config struct { Tag string `yaml:"tag"` Addr string `yaml:"addr"` Network string `yaml:"network,omitempty"` ReadTimeout time.Duration `yaml:"read_timeout,omitempty"` WriteTimeout time.Duration `yaml:"write_timeout,omitempty"` IdleTimeout time.Duration `yaml:"idle_timeout,omitempty"` ShutdownTimeout time.Duration `yaml:"shutdown_timeout,omitempty"` }
type ConfigHttpPool ¶
type ConfigHttpPool struct {
Config []Config `yaml:"http"`
}
ConfigHttpPool config to initialize HTTP service
func (*ConfigHttpPool) Default ¶
func (v *ConfigHttpPool) Default()
type Context ¶
type Context interface { URL() *url.URL Redirect(uri string) Param(key string) Param Query(key string) string Header() Header Cookie() Cookie BindBytes(in *[]byte) error BindJSON(in interface{}) error BindXML(in interface{}) error Error(code int, err error) ErrorJSON(code int, err error, ctx ErrCtx) Bytes(code int, b []byte) String(code int, b string, args ...interface{}) JSON(code int, in interface{}) Stream(code int, in []byte, filename string) Context() context.Context Request() *http.Request Response() http.ResponseWriter }
Context request and response interface
type ErrCtx ¶
type ErrCtx map[string]interface{}
func (ErrCtx) MarshalEasyJSON ¶
MarshalEasyJSON supports easyjson.Marshaler interface
func (ErrCtx) MarshalJSON ¶
MarshalJSON supports json.Marshaler interface
func (*ErrCtx) UnmarshalEasyJSON ¶
UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (*ErrCtx) UnmarshalJSON ¶
UnmarshalJSON supports json.Unmarshaler interface
type Middleware ¶
type Middleware func(func(http.ResponseWriter, *http.Request)) func(http.ResponseWriter, *http.Request)
Middleware type of middleware
func ThrottlingMiddleware ¶
func ThrottlingMiddleware(max int64) Middleware
ThrottlingMiddleware limits active requests
type RouteCollector ¶
type RouteCollector interface { Get(path string, call func(ctx Context)) Head(path string, call func(ctx Context)) Post(path string, call func(ctx Context)) Put(path string, call func(ctx Context)) Delete(path string, call func(ctx Context)) Options(path string, call func(ctx Context)) Patch(path string, call func(ctx Context)) Match(path string, call func(ctx Context), methods ...string) Collection(prefix string, args ...Middleware) RouteCollector }
RouteCollector interface of the router collection
type Router ¶
type Router interface { Use(args ...Middleware) NotFoundHandler(call func(ctx Context)) RouteCollector }
Router router handler interface
type RouterPool ¶
type RouterPool interface { // All method to get all route handlers All(call func(name string, router Router)) // Main method to get Main route handler Main() Router // Get method to get route handler by key Tag(name string) Router }
RouterPool router pool handler