Search and commands

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

Type to search packages.

router

v1.0.0
gopkg.in/zatiti/router.v1

Documentation

pkg.go.dev ↗

Table of contents

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

18 matches

Top ↑

Package router - this is a golang HTTP router that implements a trie data structure for optimal performance

Functions

Params

func Params(req *http.Request) url.Values

Params - this function returns any URL parameter if it exists

Types

Handler

type Handler func(http.ResponseWriter, *http.Request)

Handler - this a http handler middleware function

Router

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

Router - the router keeps a record of different paths and their handlers, it will direct incoming http calls to the right handler

New

func New(handler Handler) *Router

New - this method creates a new instance of a router

Router.Add

func (r *Router) Add(method, path string, handlers ...Handler)

Add - this method adds a path and it's handlers to the router

Router.Connect

func (r *Router) Connect(path string, handlers ...Handler)

Connect - add a CONNECT handler for the specified path

Router.Delete

func (r *Router) Delete(path string, handlers ...Handler)

Delete - add a DELETE handler for the specified path

Router.Get

func (r *Router) Get(path string, handlers ...Handler)

Get - add a GET handler for the specified path

Router.Options

func (r *Router) Options(path string, handlers ...Handler)

Options - add a OPTIONS handler for the specified path

Router.Params

func (r *Router) Params(req *http.Request) url.Values

Params - this method returns any URL parameter if it exists

Router.Patch

func (r *Router) Patch(path string, handlers ...Handler)

Patch - add a PATCH handler for the specified path

Router.Path

func (r *Router) Path(path string) string

Path - append a front slash to paths without it

Router.Post

func (r *Router) Post(path string, handlers ...Handler)

Post - add a POST handler for the specified path

Router.Put

func (r *Router) Put(path string, handlers ...Handler)

Put - add a PUT handler for the specified path

Router.ServeHTTP

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

ServeHTTP - this method is called every time a new request comes in

Router.Trace

func (r *Router) Trace(path string, handlers ...Handler)

Trace - add a TRACE handler for the specified path

Dependency graph