Documentation ¶
Index ¶
- type Context
- func (ctx *Context) Accepts(offers ...string) bool
- func (ctx *Context) CookieString(key string) string
- func (ctx *Context) FullUrl() string
- func (ctx *Context) GetAttribute(key ContextKey) interface{}
- func (ctx *Context) GetFormData() (map[string][]string, error)
- func (ctx *Context) GetRawContent() ([]byte, error)
- func (ctx *Context) HeaderString(key string) string
- func (ctx *Context) Host() string
- func (ctx *Context) IP() string
- func (ctx *Context) Method() string
- func (ctx *Context) NotFound()
- func (ctx *Context) ParamBool(key string) bool
- func (ctx *Context) ParamInt(key string) int
- func (ctx *Context) ParamString(key string) string
- func (ctx *Context) Path() string
- func (ctx *Context) PathAndQuery() string
- func (ctx *Context) Query() map[string]any
- func (ctx *Context) QueryBool(key string) bool
- func (ctx *Context) QueryInt(key string) int
- func (ctx *Context) QueryString(key string) string
- func (ctx *Context) Redirect(url string, statusCode int)
- func (ctx *Context) SB(data []byte)
- func (ctx *Context) SJ(data any)
- func (ctx *Context) SS(data string)
- func (ctx *Context) SendBytes(data []byte, statusCode int)
- func (ctx *Context) SendErrorJSON(message string, statusCode int)
- func (ctx *Context) SendJSON(data any, statusCode int)
- func (ctx *Context) SendStream(stream io.ReadCloser, statusCode int)
- func (ctx *Context) SendString(data string, statusCode int)
- func (ctx *Context) SetAttribute(key ContextKey, value interface{})
- func (ctx *Context) SetCookie(cookie *http.Cookie)
- func (ctx *Context) UnmarshalJSONBody(v interface{}) error
- func (ctx *Context) WriteEarlyHintScript(path string)
- func (ctx *Context) WriteEarlyHintStyle(path string)
- func (ctx *Context) WriteHeader(key string, value string)
- func (ctx *Context) WriteHeaders(headers map[string]string)
- func (ctx *Context) WriteStatus(statusCode int)
- type ContextKey
- type Handler
- type HandlerFunc
- type Map
- type Middleware
- type Router
- func (r *Router) Connect(pattern string, handler HandlerFunc)
- func (r *Router) Delete(pattern string, handler HandlerFunc)
- func (r *Router) Get(pattern string, handler HandlerFunc)
- func (r *Router) Handle(pattern string, handler http.Handler)
- func (r *Router) Head(pattern string, handler HandlerFunc)
- func (r *Router) Mount(pattern string, router *Router)
- func (r *Router) NotFound(handler HandlerFunc)
- func (r *Router) Options(pattern string, handler HandlerFunc)
- func (r *Router) Patch(pattern string, handler HandlerFunc)
- func (r *Router) Post(pattern string, handler HandlerFunc)
- func (r *Router) PrintRoutes() error
- func (r *Router) Put(pattern string, handler HandlerFunc)
- func (r *Router) Trace(pattern string, handler HandlerFunc)
- func (r *Router) Use(middleware Middleware)
- type Server
- func (s *Server) AddRoute(pattern string, subrouter *Router)
- func (s *Server) Connect(pattern string, handler HandlerFunc)
- func (s *Server) Delete(pattern string, handler HandlerFunc)
- func (s *Server) Get(pattern string, handler HandlerFunc)
- func (s *Server) Head(pattern string, handler HandlerFunc)
- func (s *Server) Options(pattern string, handler HandlerFunc)
- func (s *Server) Patch(pattern string, handler HandlerFunc)
- func (s *Server) Post(pattern string, handler HandlerFunc)
- func (s *Server) Put(pattern string, handler HandlerFunc)
- func (s *Server) Start() error
- func (s *Server) Stop() error
- func (s *Server) Trace(pattern string, handler HandlerFunc)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Context ¶
type Context struct { Request *http.Request Response http.ResponseWriter }
func Si ¶
func Si( request *http.Request, response http.ResponseWriter, ) *Context
Si creates a new context
func (*Context) CookieString ¶
CookieString gets a cookie value as a string
func (*Context) GetAttribute ¶
func (ctx *Context) GetAttribute(key ContextKey) interface{}
GetAttribute gets a value from the context
func (*Context) GetFormData ¶
GetFormData gets the form data
func (*Context) GetRawContent ¶
GetRawContent gets the raw content
func (*Context) HeaderString ¶
HeaderString gets a header value as a string
func (*Context) ParamString ¶
ParamString gets a URL parameter as a string
func (*Context) PathAndQuery ¶
PathAndQuery gets the path and query
func (*Context) QueryString ¶
QueryString gets a query parameter as a string
func (*Context) SendErrorJSON ¶
SendErrorJSON sends an error JSON response
func (*Context) SendStream ¶
func (ctx *Context) SendStream(stream io.ReadCloser, statusCode int)
SendStream sends a stream
func (*Context) SendString ¶
SendString sends a string
func (*Context) SetAttribute ¶
func (ctx *Context) SetAttribute(key ContextKey, value interface{})
SetAttribute sets a key-value pair in the context
func (*Context) SetCookie ¶ added in v1.1.0
SetCookie writes a cookie Can be used to clear a cookie by setting MaxAge to -1
func (*Context) UnmarshalJSONBody ¶
UnmarshalJSONBody unmarshals the JSON body
func (*Context) WriteEarlyHintScript ¶
WriteEarlyHintScript writes a preload hint for a script
func (*Context) WriteEarlyHintStyle ¶
WriteEarlyHintStyle writes a preload hint for a style
func (*Context) WriteHeader ¶
WriteHeader writes a header
func (*Context) WriteHeaders ¶
WriteHeaders writes multiple headers
func (*Context) WriteStatus ¶
WriteStatus writes a status code should be called after all headers are written
type ContextKey ¶
type ContextKey string
func (ContextKey) String ¶
func (c ContextKey) String() string
type HandlerFunc ¶
type HandlerFunc Handler
type Middleware ¶
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
func (*Router) Connect ¶
func (r *Router) Connect(pattern string, handler HandlerFunc)
func (*Router) Delete ¶
func (r *Router) Delete(pattern string, handler HandlerFunc)
func (*Router) Get ¶
func (r *Router) Get(pattern string, handler HandlerFunc)
func (*Router) Head ¶
func (r *Router) Head(pattern string, handler HandlerFunc)
func (*Router) NotFound ¶
func (r *Router) NotFound(handler HandlerFunc)
func (*Router) Options ¶
func (r *Router) Options(pattern string, handler HandlerFunc)
func (*Router) Patch ¶
func (r *Router) Patch(pattern string, handler HandlerFunc)
func (*Router) Post ¶
func (r *Router) Post(pattern string, handler HandlerFunc)
func (*Router) PrintRoutes ¶
func (*Router) Put ¶
func (r *Router) Put(pattern string, handler HandlerFunc)
func (*Router) Trace ¶
func (r *Router) Trace(pattern string, handler HandlerFunc)
func (*Router) Use ¶
func (r *Router) Use(middleware Middleware)
type Server ¶
type Server struct { Router *Router // contains filtered or unexported fields }
Server is a wrapper around http.Server
func CreateServer ¶
func CreateServer( listenAddress string, middlewares []Middleware, ) *Server
CreateServer creates a new server
func (*Server) Connect ¶ added in v1.1.0
func (s *Server) Connect(pattern string, handler HandlerFunc)
func (*Server) Delete ¶ added in v1.1.0
func (s *Server) Delete(pattern string, handler HandlerFunc)
func (*Server) Get ¶ added in v1.1.0
func (s *Server) Get(pattern string, handler HandlerFunc)
func (*Server) Head ¶ added in v1.1.0
func (s *Server) Head(pattern string, handler HandlerFunc)
func (*Server) Options ¶ added in v1.1.0
func (s *Server) Options(pattern string, handler HandlerFunc)
func (*Server) Patch ¶ added in v1.1.0
func (s *Server) Patch(pattern string, handler HandlerFunc)
func (*Server) Post ¶ added in v1.1.0
func (s *Server) Post(pattern string, handler HandlerFunc)
func (*Server) Put ¶ added in v1.1.0
func (s *Server) Put(pattern string, handler HandlerFunc)
func (*Server) Trace ¶ added in v1.1.0
func (s *Server) Trace(pattern string, handler HandlerFunc)