Documentation
¶
Index ¶
- func AddContextValue(req *http.Request, key, value any)
- func File(contentType string, f io.Reader) func(w http.ResponseWriter, req *http.Request)
- func GetContextValue[t any](req *http.Request, key any, value *t) bool
- func Handle(handlers ...any) func(w http.ResponseWriter, req *http.Request)
- func HasContextValue[t any](req *http.Request, key any) bool
- func Html(str string) func(w http.ResponseWriter, req *http.Request)
- func PathParams(req *http.Request) map[any]string
- func Recover(req *http.Request) any
- type ChainHandler
- type ResponseBuilder
- type ResponseWriter
- type Router
- func (r *Router) Delete(pathExpr string, handler http.HandlerFunc) *Router
- func (r *Router) Get(pathExpr string, handler http.HandlerFunc) *Router
- func (r *Router) NotFoundHandler(handler http.HandlerFunc) *Router
- func (r *Router) Patch(pathExpr string, handler http.HandlerFunc) *Router
- func (r *Router) Post(pathExpr string, handler http.HandlerFunc) *Router
- func (r *Router) PostFilters(filters ...http.HandlerFunc) *Router
- func (r *Router) PreFilters(filters ...http.HandlerFunc) *Router
- func (r *Router) Put(pathExpr string, handler http.HandlerFunc) *Router
- func (r *Router) RecoverHandler(handler http.HandlerFunc) *Router
- func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request)
- func (r *Router) SubRoute(pathExpr string, router *Router) *Router
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddContextValue ¶
Types ¶
type ChainHandler ¶
type ChainHandler func(http.ResponseWriter, *http.Request) bool
var Get ChainHandler = Method("GET")
var Path ChainHandler = Method("PATCH")
var Post ChainHandler = Method("POST")
var Put ChainHandler = Method("PUT")
func BasicAuthHandler ¶
func BasicAuthHandler(user, pass string) ChainHandler
func Method ¶
func Method(method string) ChainHandler
func NopHandler ¶
func NopHandler() ChainHandler
type ResponseBuilder ¶
type ResponseBuilder interface { Status(status int) ResponseBuilder WithBody(body any) ResponseBuilder WithHeader(key, value string) ResponseBuilder WithCookie(cookie *http.Cookie) ResponseBuilder Redirect(redirect string) HtmlTemplate(temp *template.Template, data any) As(contentType string) AsTextPlain() AsJson() AsHtml() }
func Response ¶
func Response(w http.ResponseWriter) ResponseBuilder
type ResponseWriter ¶ added in v1.1.0
type ResponseWriter interface { http.ResponseWriter Status() int Written() bool Size() int }
func NewResponseWriter ¶ added in v1.1.0
func NewResponseWriter(rw http.ResponseWriter) ResponseWriter
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
func (*Router) Delete ¶ added in v1.1.0
func (r *Router) Delete(pathExpr string, handler http.HandlerFunc) *Router
func (*Router) Get ¶ added in v1.1.0
func (r *Router) Get(pathExpr string, handler http.HandlerFunc) *Router
func (*Router) NotFoundHandler ¶ added in v1.1.0
func (r *Router) NotFoundHandler(handler http.HandlerFunc) *Router
func (*Router) Patch ¶ added in v1.1.0
func (r *Router) Patch(pathExpr string, handler http.HandlerFunc) *Router
func (*Router) Post ¶ added in v1.1.0
func (r *Router) Post(pathExpr string, handler http.HandlerFunc) *Router
func (*Router) PostFilters ¶ added in v1.1.0
func (r *Router) PostFilters(filters ...http.HandlerFunc) *Router
func (*Router) PreFilters ¶ added in v1.1.0
func (r *Router) PreFilters(filters ...http.HandlerFunc) *Router
func (*Router) Put ¶ added in v1.1.0
func (r *Router) Put(pathExpr string, handler http.HandlerFunc) *Router
func (*Router) RecoverHandler ¶ added in v1.1.0
func (r *Router) RecoverHandler(handler http.HandlerFunc) *Router
Click to show internal directories.
Click to hide internal directories.