Documentation ¶
Index ¶
- func MiddlewareWrapper(options *Cors) func(*HttpContext, func(error))
- type Callable
- type CodeMessage
- type Cors
- type ErrorMessage
- type HttpCompression
- type HttpContext
- func (c *HttpContext) Context() context.Context
- func (c *HttpContext) Done() <-chan struct{}
- 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) Request() *http.Request
- func (c *HttpContext) Response() http.ResponseWriter
- 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
- func (s *HttpServer) Close(fn Callable) error
- func (s *HttpServer) Listen(addr string, fn Callable) *HttpServer
- func (s *HttpServer) ListenHTTP2TLS(addr string, certFile string, keyFile string, conf *http2.Server, fn Callable) *HttpServer
- func (s *HttpServer) ListenTLS(addr string, certFile string, keyFile string, fn Callable) *HttpServer
- type Kv
- type PerMessageDeflate
- type ServeMux
- func (mux *ServeMux) Handle(pattern string, handler http.Handler)
- func (mux *ServeMux) HandleFunc(pattern string, handler func(http.ResponseWriter, *http.Request))
- func (mux *ServeMux) Handler(r *http.Request) (h http.Handler, pattern string)
- func (mux *ServeMux) ServeHTTP(w http.ResponseWriter, r *http.Request)
- type Set
- type Void
- type WebSocketConn
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MiddlewareWrapper ¶
func MiddlewareWrapper(options *Cors) func(*HttpContext, func(error))
Types ¶
type CodeMessage ¶
type Cors ¶
type Cors struct { Origin any `json:"origin,omitempty"` Methods any `json:"methods,omitempty"` AllowedHeaders any `json:"allowedHeaders,omitempty"` Headers any `json:"headers,omitempty"` ExposedHeaders any `json:"exposedHeaders,omitempty"` MaxAge string `json:"maxAge,omitempty"` Credentials bool `json:"credentials,omitempty"` PreflightContinue bool `json:"preflightContinue,omitempty"` OptionsSuccessStatus int `json:"optionsSuccessStatus,omitempty"` }
type ErrorMessage ¶
type ErrorMessage struct { *CodeMessage Req *HttpContext `json:"req,omitempty"` Context map[string]any `json:"context,omitempty"` }
type HttpCompression ¶
type HttpCompression struct {
Threshold int `json:"threshold,omitempty"`
}
type HttpContext ¶
type HttpContext struct { events.EventEmitter Websocket *WebSocketConn Cleanup Callable ResponseHeaders *utils.ParameterBag // contains filtered or unexported fields }
func NewHttpContext ¶
func NewHttpContext(w http.ResponseWriter, r *http.Request) *HttpContext
func (*HttpContext) Context ¶
func (c *HttpContext) Context() context.Context
func (*HttpContext) Done ¶
func (c *HttpContext) Done() <-chan struct{}
func (*HttpContext) Flush ¶ added in v1.0.12
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 ¶ added in v1.1.14
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) Request ¶
func (c *HttpContext) Request() *http.Request
func (*HttpContext) Response ¶
func (c *HttpContext) Response() http.ResponseWriter
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 ¶
func CreateServer(defaultHandler http.Handler) *HttpServer
func (*HttpServer) Close ¶ added in v1.0.8
func (s *HttpServer) Close(fn Callable) error
func (*HttpServer) Listen ¶
func (s *HttpServer) Listen(addr string, fn Callable) *HttpServer
func (*HttpServer) ListenHTTP2TLS ¶ added in v1.4.5
func (s *HttpServer) ListenHTTP2TLS(addr string, certFile string, keyFile string, conf *http2.Server, fn Callable) *HttpServer
func (*HttpServer) ListenTLS ¶
func (s *HttpServer) ListenTLS(addr string, certFile string, keyFile string, fn Callable) *HttpServer
type PerMessageDeflate ¶
type PerMessageDeflate struct {
Threshold int `json:"threshold,omitempty"`
}
type ServeMux ¶ added in v1.0.8
type ServeMux struct { DefaultHandler http.Handler // Default Handler // contains filtered or unexported fields }
func NewServeMux ¶ added in v1.0.8
NewServeMux allocates and returns a new ServeMux.
func (*ServeMux) Handle ¶ added in v1.0.8
Handle registers the handler for the given pattern. If a handler already exists for pattern, Handle panics.
func (*ServeMux) HandleFunc ¶ added in v1.0.8
HandleFunc registers the handler function for the given pattern.
func (*ServeMux) Handler ¶ added in v1.0.8
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 Set ¶
type Set[T comparable] struct { // contains filtered or unexported fields }
func NewSet ¶
func NewSet[T comparable](keys ...T) *Set[T]
type WebSocketConn ¶
type WebSocketConn struct { events.EventEmitter *websocket.Conn }