chi – github.com/go-chi/chi Index | Files | Directories
Deprecated: Please upgrade to the latest major version: go get github.com/go-chi/chi/v5

package chi

import "github.com/go-chi/chi"

Index

Functions

func URLParam

func URLParam(ctx context.Context, key string) string

Types

type Context

type Context struct {
	context.Context
	// contains filtered or unexported fields
}

func RootContext

func RootContext(ctx context.Context) *Context

Returns the root level chi Context object

func (*Context) Param

func (x *Context) Param(key string) string

type 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.

type HandlerFunc

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

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

func (HandlerFunc) ServeHTTP

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

ServeHTTP provides compatibility with http.Handler.

func (HandlerFunc) ServeHTTPC

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

ServeHTTPC wraps ServeHTTP with a context parameter.

type Mux

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

func NewMux

func NewMux() *Mux

func NewRouter

func NewRouter() *Mux

func (*Mux) Connect

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

func (*Mux) Delete

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

func (*Mux) Get

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

func (*Mux) Group

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

func (*Mux) Handle

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

func (*Mux) Head

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

func (*Mux) Mount

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

func (*Mux) NotFound

func (mx *Mux) NotFound(h HandlerFunc)

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

func (*Mux) Options

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

func (*Mux) Patch

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

func (*Mux) Post

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

func (*Mux) Put

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

func (*Mux) Route

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

func (*Mux) ServeHTTP

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

func (*Mux) ServeHTTPC

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

func (*Mux) Trace

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

func (*Mux) Use

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

Append to the middleware stack

type 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{})
}

type 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.

Source Files

chi.go context.go mux.go tree.go util.go

Directories

PathSynopsis
_examples
_examples/rest
_examples/simple
middleware
render
Version
v0.9.0
Published
Mar 31, 2016
Platform
js/wasm
Imports
6 packages
Last checked
4 days ago

Tools for package owners.