Documentation ¶
Index ¶
- func CorsMiddleware(options *Cors, ctx *HttpContext, next func(error))
- func MiddlewareWrapper(options *Cors) func(*HttpContext, func(error))
- type CodeMessage
- type Cors
- type ErrorMessage
- type Handler
- type HandlerFunc
- type HttpContext
- func (c *HttpContext) Done() <-chan _types.Void
- func (c *HttpContext) Flush()
- func (c *HttpContext) Get(key string, _default ...string) string
- func (c *HttpContext) GetHost() (string, error)
- func (c *HttpContext) GetMethod() string
- func (c *HttpContext) GetPathInfo() string
- func (c *HttpContext) GetStatusCode() int
- func (c *HttpContext) Gets(key string, _default ...[]string) []string
- func (c *HttpContext) Headers() *utils.ParameterBag
- func (c *HttpContext) IsDone() bool
- func (c *HttpContext) Method() string
- func (c *HttpContext) Path() string
- func (c *HttpContext) Query() *utils.ParameterBag
- func (c *HttpContext) RequestCtx() *fasthttp.RequestCtx
- func (c *HttpContext) Secure() bool
- func (c *HttpContext) SetStatusCode(statusCode int)
- func (c *HttpContext) UserAgent() string
- func (c *HttpContext) Write(wb []byte) (int, error)
- type HttpServer
- type Kv
- type ServeMux
- type WebSocketConn
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CorsMiddleware ¶
func CorsMiddleware(options *Cors, ctx *HttpContext, next func(error))
func MiddlewareWrapper ¶
func MiddlewareWrapper(options *Cors) func(*HttpContext, func(error))
Types ¶
type CodeMessage ¶
type Cors ¶
type Cors struct { Origin any `json:"origin,omitempty" mapstructure:"origin,omitempty" msgpack:"origin,omitempty"` Methods any `json:"methods,omitempty" mapstructure:"methods,omitempty" msgpack:"methods,omitempty"` AllowedHeaders any `json:"allowedHeaders,omitempty" mapstructure:"allowedHeaders,omitempty" msgpack:"allowedHeaders,omitempty"` Headers any `json:"headers,omitempty" mapstructure:"headers,omitempty" msgpack:"headers,omitempty"` ExposedHeaders any `json:"exposedHeaders,omitempty" mapstructure:"exposedHeaders,omitempty" msgpack:"exposedHeaders,omitempty"` MaxAge string `json:"maxAge,omitempty" mapstructure:"maxAge,omitempty" msgpack:"maxAge,omitempty"` Credentials bool `json:"credentials,omitempty" mapstructure:"credentials,omitempty" msgpack:"credentials,omitempty"` PreflightContinue bool `json:"preflightContinue,omitempty" mapstructure:"preflightContinue,omitempty" msgpack:"preflightContinue,omitempty"` OptionsSuccessStatus int `json:"optionsSuccessStatus,omitempty" mapstructure:"optionsSuccessStatus,omitempty" msgpack:"optionsSuccessStatus,omitempty"` }
type ErrorMessage ¶
type ErrorMessage struct { *CodeMessage Req *HttpContext `json:"req,omitempty" mapstructure:"req,omitempty" msgpack:"req,omitempty"` Context map[string]any `json:"context,omitempty" mapstructure:"context,omitempty" msgpack:"context,omitempty"` }
type Handler ¶
type Handler interface {
FastHTTP(*fasthttp.RequestCtx)
}
type HandlerFunc ¶
type HandlerFunc fasthttp.RequestHandler
func (HandlerFunc) FastHTTP ¶
func (h HandlerFunc) FastHTTP(ctx *fasthttp.RequestCtx)
type HttpContext ¶
type HttpContext struct { events.EventEmitter Websocket *WebSocketConn Cleanup _types.Callable ResponseHeaders *utils.ParameterBag // contains filtered or unexported fields }
func NewHttpContext ¶
func NewHttpContext(ctx *fasthttp.RequestCtx) *HttpContext
func (*HttpContext) Done ¶
func (c *HttpContext) Done() <-chan _types.Void
func (*HttpContext) Flush ¶
func (c *HttpContext) Flush()
func (*HttpContext) GetHost ¶
func (c *HttpContext) GetHost() (string, error)
func (*HttpContext) GetMethod ¶
func (c *HttpContext) GetMethod() string
func (*HttpContext) GetPathInfo ¶
func (c *HttpContext) GetPathInfo() string
func (*HttpContext) GetStatusCode ¶
func (c *HttpContext) GetStatusCode() int
func (*HttpContext) Headers ¶
func (c *HttpContext) Headers() *utils.ParameterBag
func (*HttpContext) IsDone ¶
func (c *HttpContext) IsDone() bool
func (*HttpContext) Method ¶
func (c *HttpContext) Method() string
func (*HttpContext) Path ¶
func (c *HttpContext) Path() string
func (*HttpContext) Query ¶
func (c *HttpContext) Query() *utils.ParameterBag
func (*HttpContext) RequestCtx ¶
func (c *HttpContext) RequestCtx() *fasthttp.RequestCtx
func (*HttpContext) Secure ¶
func (c *HttpContext) Secure() bool
func (*HttpContext) SetStatusCode ¶
func (c *HttpContext) SetStatusCode(statusCode int)
func (*HttpContext) UserAgent ¶
func (c *HttpContext) UserAgent() string
type HttpServer ¶
type HttpServer struct { events.EventEmitter *ServeMux // contains filtered or unexported fields }
func CreateServer
deprecated
func CreateServer(defaultHandler Handler) *HttpServer
Deprecated: this method will be removed in the next major release, please use NewWebServer instead.
func NewWebServer ¶
func NewWebServer(defaultHandler Handler) *HttpServer
func (*HttpServer) Close ¶
func (s *HttpServer) Close(fn func(error)) (err error)
type ServeMux ¶
type ServeMux struct { DefaultHandler Handler // Default Handler // contains filtered or unexported fields }
func NewServeMux ¶
NewServeMux allocates and returns a new ServeMux.
func (*ServeMux) FastHTTP ¶
func (mux *ServeMux) FastHTTP(ctx *fasthttp.RequestCtx)
FastHTTP dispatches the request to the handler whose pattern most closely matches the request URL.
func (*ServeMux) Handle ¶
Handle registers the handler for the given pattern. If a handler already exists for pattern, Handle panics.
func (*ServeMux) HandleFunc ¶
func (mux *ServeMux) HandleFunc(pattern string, handler func(*fasthttp.RequestCtx))
HandleFunc registers the handler function for the given pattern.
func (*ServeMux) Handler ¶
func (mux *ServeMux) Handler(ctx *fasthttp.RequestCtx) (h Handler, pattern string)
Handler returns the handler to use for the given request, consulting r.Method, r.Host, and r.URL.Path. It always returns a non-nil handler. If the path is not in its canonical form, the handler will be an internally-generated handler that redirects to the canonical path. If the host contains a port, it is ignored when matching handlers.
The path and host are used unchanged for CONNECT requests.
Handler also returns the registered pattern that matches the request or, in the case of internally-generated redirects, the pattern that will match after following the redirect.
If there is no registered handler that applies to the request, Handler returns a “page not found” handler and an empty pattern.
type WebSocketConn ¶
type WebSocketConn struct { events.EventEmitter *websocket.Conn // contains filtered or unexported fields }
func MakeWebSocketConn ¶
func MakeWebSocketConn() *WebSocketConn
func NewWebSocketConn ¶
func NewWebSocketConn() *WebSocketConn
func (*WebSocketConn) Close ¶
func (t *WebSocketConn) Close() error
func (*WebSocketConn) Done ¶
func (t *WebSocketConn) Done() <-chan _types.Void