types

package
v2.1.1 Latest Latest
Warning

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

Go to latest
Published: May 30, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

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 CodeMessage struct {
	Code    int    `json:"code" mapstructure:"code" msgpack:"code"`
	Message string `json:"message,omitempty" mapstructure:"message,omitempty" msgpack:"message,omitempty"`
}

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) Get

func (c *HttpContext) Get(key string, _default ...string) string

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) Gets

func (c *HttpContext) Gets(key string, _default ...[]string) []string

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

func (*HttpContext) Write

func (c *HttpContext) Write(wb []byte) (int, error)

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)

func (*HttpServer) Listen

func (s *HttpServer) Listen(addr string, fn _types.Callable) *fasthttp.Server

func (*HttpServer) ListenTLS

func (s *HttpServer) ListenTLS(addr string, certFile string, keyFile string, fn _types.Callable) *fasthttp.Server

type Kv

type Kv struct {
	Key   string
	Value string
}

type ServeMux

type ServeMux struct {
	DefaultHandler Handler // Default Handler
	// contains filtered or unexported fields
}

func NewServeMux

func NewServeMux(defaultHandler Handler) *ServeMux

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

func (mux *ServeMux) Handle(pattern string, handler Handler)

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) Construct

func (t *WebSocketConn) Construct()

WebSocketConn Construct.

func (*WebSocketConn) Done

func (t *WebSocketConn) Done() <-chan _types.Void

Jump to

Keyboard shortcuts

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