router

package
v0.0.0-...-ecdd364 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package router provides request handling capabilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Mux

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

Mux contains the router.

func New

func New() *Mux

New returns an instance of the router.

func (*Mux) Delete

func (m *Mux) Delete(path string, fn func(http.ResponseWriter, *http.Request) error)

Delete registers a pattern with the router.

func (*Mux) Error

func (m *Mux) Error(status int, w http.ResponseWriter, r *http.Request)

Error shows error page based on the status code.

func (*Mux) Get

func (m *Mux) Get(path string, fn func(http.ResponseWriter, *http.Request) error)

Get registers a pattern with the router.

func (*Mux) Handle

func (m *Mux) Handle(method string, path string, fn func(http.ResponseWriter, *http.Request) error)

Handle registers a method and pattern with the router.

func (*Mux) Head

func (m *Mux) Head(path string, fn func(http.ResponseWriter, *http.Request) error)

Head registers a pattern with the router.

func (*Mux) Options

func (m *Mux) Options(path string, fn func(http.ResponseWriter, *http.Request) error)

Options registers a pattern with the router.

func (*Mux) Param

func (m *Mux) Param(r *http.Request, param string) string

Param returns a URL parameter.

func (*Mux) Patch

func (m *Mux) Patch(path string, fn func(http.ResponseWriter, *http.Request) error)

Patch registers a pattern with the router.

func (*Mux) Post

func (m *Mux) Post(path string, fn func(http.ResponseWriter, *http.Request) error)

Post registers a pattern with the router.

func (*Mux) Put

func (m *Mux) Put(path string, fn func(http.ResponseWriter, *http.Request) error)

Put registers a pattern with the router.

func (*Mux) ServeHTTP

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

ServeHTTP routes the incoming http.Request based on method and path extracting path parameters as it goes.

func (*Mux) SetNotFound

func (m *Mux) SetNotFound(notFound http.Handler)

SetNotFound sets the NotFound function.

func (*Mux) SetServeHTTP

func (m *Mux) SetServeHTTP(csh func(w http.ResponseWriter, r *http.Request, err error))

SetServeHTTP sets the ServeHTTP function.

func (*Mux) StatusError

func (m *Mux) StatusError(status int, err error) error

StatusError returns error with a status code.

func (*Mux) Wrap

func (m *Mux) Wrap(handler http.HandlerFunc) func(w http.ResponseWriter, r *http.Request) (err error)

Wrap a standard http handler so it can be used easily.

Jump to

Keyboard shortcuts

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