ruuto

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultOptions = Options{
	NotFoundHandler:           http.NotFound,
	SafeAddRoutesWhileRunning: true,
}

DefaultOptions are the default router options

Functions

func Logger

func Logger() func(next http.Handler) http.Handler

func Recovery

func Recovery() func(next http.Handler) http.Handler

func URLParam

func URLParam(r *http.Request, key string) string

URLParam returns the url parameter from a http.Request object.

Types

type ChiRouter

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

ChiRouter is an adapter for chi router that implements the Router interface

func NewChiRouter

func NewChiRouter() *ChiRouter

NewChiRouter creates a new instance of ChiRouter

func NewChiRouterWithOptions

func NewChiRouterWithOptions(options Options) *ChiRouter

NewChiRouterWithOptions creates a new instance of ChiRouter with the provided options

func (*ChiRouter) Any

func (r *ChiRouter) Any(path string, handler http.HandlerFunc, handlers ...Constructor)

Any register a path to all HTTP methods

func (*ChiRouter) CONNECT

func (r *ChiRouter) CONNECT(path string, handler http.HandlerFunc, handlers ...Constructor)

CONNECT registers a HTTP CONNECT path

func (*ChiRouter) DELETE

func (r *ChiRouter) DELETE(path string, handler http.HandlerFunc, handlers ...Constructor)

DELETE registers a HTTP DELETE path

func (*ChiRouter) GET

func (r *ChiRouter) GET(path string, handler http.HandlerFunc, handlers ...Constructor)

GET registers a HTTP GET path

func (*ChiRouter) Group

func (r *ChiRouter) Group(path string) Router

Group creates a child router for a specific path

func (*ChiRouter) HEAD

func (r *ChiRouter) HEAD(path string, handler http.HandlerFunc, handlers ...Constructor)

HEAD registers a HTTP HEAD path

func (*ChiRouter) Handle

func (r *ChiRouter) Handle(method string, path string, handler http.HandlerFunc, handlers ...Constructor)

Handle registers a path, method and handlers to the router

func (*ChiRouter) OPTIONS

func (r *ChiRouter) OPTIONS(path string, handler http.HandlerFunc, handlers ...Constructor)

OPTIONS registers a HTTP OPTIONS path

func (*ChiRouter) PATCH

func (r *ChiRouter) PATCH(path string, handler http.HandlerFunc, handlers ...Constructor)

PATCH registers a HTTP PATCH path

func (*ChiRouter) POST

func (r *ChiRouter) POST(path string, handler http.HandlerFunc, handlers ...Constructor)

POST registers a HTTP POST path

func (*ChiRouter) PUT

func (r *ChiRouter) PUT(path string, handler http.HandlerFunc, handlers ...Constructor)

PUT registers a HTTP PUT path

func (*ChiRouter) RoutesCount

func (r *ChiRouter) RoutesCount() int

RoutesCount returns number of routes registered

func (*ChiRouter) ServeHTTP

func (r *ChiRouter) ServeHTTP(w http.ResponseWriter, req *http.Request)

ServeHTTP server the HTTP requests

func (*ChiRouter) TRACE

func (r *ChiRouter) TRACE(path string, handler http.HandlerFunc, handlers ...Constructor)

TRACE registers a HTTP TRACE path

func (*ChiRouter) Use

func (r *ChiRouter) Use(handlers ...Constructor) Router

Use attaches a middleware to the router

type Constructor

type Constructor func(http.Handler) http.Handler

Constructor for a piece of middleware. Some middleware use this constructor out of the box, so in most cases you can just pass somepackage.New

type Options

type Options struct {
	NotFoundHandler           http.HandlerFunc
	SafeAddRoutesWhileRunning bool
}

Options are the HTTPTreeMuxRouter options

type Router

type Router interface {
	ServeHTTP(w http.ResponseWriter, req *http.Request)
	Handle(method string, path string, handler http.HandlerFunc, handlers ...Constructor)
	Any(path string, handler http.HandlerFunc, handlers ...Constructor)
	GET(path string, handler http.HandlerFunc, handlers ...Constructor)
	POST(path string, handler http.HandlerFunc, handlers ...Constructor)
	PUT(path string, handler http.HandlerFunc, handlers ...Constructor)
	DELETE(path string, handler http.HandlerFunc, handlers ...Constructor)
	PATCH(path string, handler http.HandlerFunc, handlers ...Constructor)
	HEAD(path string, handler http.HandlerFunc, handlers ...Constructor)
	OPTIONS(path string, handler http.HandlerFunc, handlers ...Constructor)
	TRACE(path string, handler http.HandlerFunc, handlers ...Constructor)
	CONNECT(path string, handler http.HandlerFunc, handlers ...Constructor)
	Group(path string) Router
	Use(handlers ...Constructor) Router

	RoutesCount() int
}

Router defines the basic methods for a router

Jump to

Keyboard shortcuts

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