Search and commands

↑ ↓ to select · Enter to open · Esc to close

Type to search packages.

chi

v1.0.0
github.com/glkz/chi

Documentation

pkg.go.dev ↗

Table of contents

↓ to select · Enter to jump· Shift+Enter for source

32 matches

Top ↑

Constants

URLParamsCtxKey (2 declarations)

const (
	URLParamsCtxKey ctxKey = iota
	SubRouterCtxKey
)

Functions

URLParams

func URLParams(ctx context.Context) map[string]string

Types

Handler

type Handler interface {
	ServeHTTPC(context.Context, http.ResponseWriter, *http.Request)
}

Handler is like net/http's http.Handler, but also includes a mechanism for serving requests with a context.

HandlerFunc

type HandlerFunc func(context.Context, http.ResponseWriter, *http.Request)

HandlerFunc is like net/http's http.HandlerFunc, but supports a context object.

HandlerFunc.ServeHTTP

func (h HandlerFunc) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP provides compatibility with http.Handler.

HandlerFunc.ServeHTTPC

func (h HandlerFunc) ServeHTTPC(ctx context.Context, w http.ResponseWriter, r *http.Request)

ServeHTTPC wraps ServeHTTP with a context parameter.

Mux

type Mux struct {
	// contains filtered or unexported fields
}

NewMux

func NewMux() *Mux

NewRouter

func NewRouter() *Mux

Mux.Connect

func (mx *Mux) Connect(pattern string, handlers ...interface{})

Mux.Delete

func (mx *Mux) Delete(pattern string, handlers ...interface{})

Mux.Get

func (mx *Mux) Get(pattern string, handlers ...interface{})

Mux.Group

func (mx *Mux) Group(fn func(r Router)) Router

Mux.Handle

func (mx *Mux) Handle(pattern string, handlers ...interface{})

Mux.Head

func (mx *Mux) Head(pattern string, handlers ...interface{})

Mux.Mount

func (mx *Mux) Mount(path string, handlers ...interface{})

Mux.NotFound

func (mx *Mux) NotFound(h HandlerFunc)

NotFound sets a custom handler for the case when no routes match

Mux.Options

func (mx *Mux) Options(pattern string, handlers ...interface{})

Mux.Patch

func (mx *Mux) Patch(pattern string, handlers ...interface{})

Mux.Post

func (mx *Mux) Post(pattern string, handlers ...interface{})

Mux.Put

func (mx *Mux) Put(pattern string, handlers ...interface{})

Mux.Route

func (mx *Mux) Route(pattern string, fn func(r Router)) Router

Mux.ServeHTTP

func (mx *Mux) ServeHTTP(w http.ResponseWriter, r *http.Request)

Mux.ServeHTTPC

func (mx *Mux) ServeHTTPC(ctx context.Context, w http.ResponseWriter, r *http.Request)

Mux.Trace

func (mx *Mux) Trace(pattern string, handlers ...interface{})

Mux.Use

func (mx *Mux) Use(mws ...interface{})

Append to the middleware stack

Router

type Router interface {
	http.Handler
	Handler

	Use(middlewares ...interface{})
	Group(fn func(r Router)) Router
	Route(pattern string, fn func(r Router)) Router
	Mount(pattern string, handlers ...interface{})

	Handle(pattern string, handlers ...interface{})
	NotFound(h HandlerFunc)

	Connect(pattern string, handlers ...interface{})
	Head(pattern string, handlers ...interface{})
	Get(pattern string, handlers ...interface{})
	Post(pattern string, handlers ...interface{})
	Put(pattern string, handlers ...interface{})
	Patch(pattern string, handlers ...interface{})
	Delete(pattern string, handlers ...interface{})
	Trace(pattern string, handlers ...interface{})
	Options(pattern string, handlers ...interface{})
}

WalkFn

type WalkFn func(path string, handler Handler) bool

WalkFn is used when walking the tree. Takes a key and value, returning if iteration should be terminated.

Dependency graph