Documentation ¶
Index ¶
- type Context
- func (c *Context) Bind(v any) error
- func (c *Context) ClientIP() string
- func (c *Context) ContentLength() int64
- func (c *Context) ContentType() (ct string)
- func (c *Context) GetQuery(key string) string
- func (c *Context) GetRequestHeader(key string) string
- func (c *Context) IsWebSocket() bool
- func (c *Context) JSON(code int, obj any) error
- func (c *Context) JSONP(code int, obj any) error
- func (c *Context) Query() url.Values
- func (c *Context) QueryMap() map[string]any
- func (c *Context) Render(code int, r render.Render) error
- func (c *Context) ShouldBindJSON(obj any) error
- func (c *Context) ShouldBindQuery(obj any) error
- func (c *Context) ShouldBindWith(obj any, b binder.Binder) error
- func (c *Context) String(code int, format string, values ...any) error
- type HandlerFunc
- type MiddlewareFunc
- type ResponseWriter
- type Zeus
- func (z *Zeus) AcquireContext(r *http.Request, w http.ResponseWriter) *Context
- func (z *Zeus) ErrHandler(c *Context, err error)
- func (z *Zeus) Handler(name string) (HandlerFunc, bool)
- func (z *Zeus) Register(action string, handler HandlerFunc, mws ...MiddlewareFunc)
- func (z *Zeus) ReleaseContext(c *Context)
- func (z *Zeus) Run(addr ...string) (err error)
- func (z *Zeus) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (z *Zeus) Use(mws ...MiddlewareFunc)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Context ¶
type Context struct { Action string Request *http.Request Writer ResponseWriter Buf []byte Zeus *Zeus // contains filtered or unexported fields }
func (*Context) Bind ¶
Bind is used to bind the request to v, set the default and validate the data.
func (*Context) ContentLength ¶
ContentLength return the length of the request body.
func (*Context) ContentType ¶
ContentType returns the Content-Type of the request without the charset.
func (*Context) GetRequestHeader ¶
GetRequestHeader is equal to c.Request().Header.Get(key).
func (*Context) IsWebSocket ¶
IsWebSocket reports whether HTTP connection is WebSocket or not.
func (*Context) JSONP ¶
JSONP serializes the given struct as JSON into the response body. It adds padding to response body to request data from a server residing in a different domain than the client. It also sets the Content-Type as "application/javascript".
func (*Context) ShouldBindJSON ¶
ShouldBindJSON is a shortcut for c.ShouldBindWith(obj, binder.Json).
func (*Context) ShouldBindQuery ¶
ShouldBindQuery is a shortcut for c.ShouldBindWith(obj, binder.Query).
func (*Context) ShouldBindWith ¶
ShouldBindWith binds the passed struct pointer using the specified binder engine. See the binder package.
type MiddlewareFunc ¶
type MiddlewareFunc func(HandlerFunc) HandlerFunc
MiddlewareFunc is the handler middleware.
type ResponseWriter ¶
type ResponseWriter interface { http.ResponseWriter Status() int Size() int WriteString(string) (int, error) Written() bool WriteHeaderNow() }
ResponseWriter ...
type Zeus ¶
type Zeus struct {
// contains filtered or unexported fields
}
func (*Zeus) AcquireContext ¶
AcquireContext acquires a Context from the pool.
func (*Zeus) ErrHandler ¶
func (*Zeus) Register ¶
func (z *Zeus) Register(action string, handler HandlerFunc, mws ...MiddlewareFunc)
Register registers a service with the name and the handler.
func (*Zeus) ReleaseContext ¶
ReleaseContext releases a Context into the pool.
func (*Zeus) Use ¶
func (z *Zeus) Use(mws ...MiddlewareFunc)
Use registers the global middlewares that apply to all the services.