mux

package module
v0.0.0-...-0c702f1 Latest Latest
Warning

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

Go to latest
Published: May 13, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Join

func Join(elems ...string) string

func Ok

func Ok(c *Context, w http.ResponseWriter, req *http.Request) error

Types

type Context

type Context struct {
	Context context.Context

	KV map[any]any

	Timestamp time.Time

	Mux *Mux
	// contains filtered or unexported fields
}

func ContextFrom

func ContextFrom(ctx context.Context) *Context

func (*Context) Break

func (c *Context) Break()

func (*Context) Next

func (c *Context) Next(w http.ResponseWriter, req *http.Request) (err error)

func (*Context) RespondJSON

func (c *Context) RespondJSON(w http.ResponseWriter, v any) error

func (*Context) RespondJSONCode

func (c *Context) RespondJSONCode(w http.ResponseWriter, v any, code int) error

func (*Context) SetKV

func (c *Context) SetKV(k, v any)

func (*Context) UnmarshalRequestJSON

func (c *Context) UnmarshalRequestJSON(req *http.Request, v any) error

type Handler

type Handler = func(c *Context, w http.ResponseWriter, req *http.Request) error

func Redirect

func Redirect(url string) Handler

func RedirectCode

func RedirectCode(url string, code int) Handler

func WrapStdHandler

func WrapStdHandler(h http.Handler) Handler

func WrapStdHandlerFunc

func WrapStdHandlerFunc(f http.HandlerFunc) Handler

type Middleware

type Middleware = Handler

func Alert

func Alert(format string, args ...any) Middleware

func Deprecate

func Deprecate(t time.Time) Middleware
func Link(url, rel, typ string) Middleware

func Sunset

func Sunset(t time.Time) Middleware

type Mux

type Mux struct {
	Router

	ServeMux http.ServeMux

	// Middlewares that run regardless of whether a handler was found or not.
	Middlewares []Middleware
	NotFound    Handler

	// OnHandle is called each time handler is registered. If set.
	OnHandle func(pattern string, h Handler, ms []Middleware)
}

func New

func New() *Mux

func (*Mux) ServeHTTP

func (m *Mux) ServeHTTP(w http.ResponseWriter, req *http.Request)

type Router

type Router struct {
	Path string
	// contains filtered or unexported fields
}

func (*Router) Group

func (r *Router) Group(path string, ms ...Middleware) *Router

func (*Router) Handle

func (r *Router) Handle(pattern string, h Handler, ms ...Middleware)

func (*Router) Use

func (r *Router) Use(ms ...Middleware)

Jump to

Keyboard shortcuts

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