router

package
v0.0.0-...-0d82576 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Pakage router implements simple http routing using net/http.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Middleware

type Middleware func(next http.Handler) http.Handler

type Root

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

func NewRootRouter

func NewRootRouter() *Root

func (*Root) Group

func (router *Root) Group(prefix string) *RouteGroup

Group adds a new RouteGroup to the router.

func (*Root) Mux

func (router *Root) Mux() *http.ServeMux

func (*Root) RouteFunc

func (router *Root) RouteFunc(route string, f func(http.ResponseWriter, *http.Request))

RouteFunc adds a route that is handled by a function

func (*Root) Use

func (router *Root) Use(middleware Middleware)

Use adds a middleware that is used for all routes in the router. Middlewares are applied in the same order `Use` is called.

type RouteGroup

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

RouteGroup groups related routes under a common prefix and use the same middlewares.

func (*RouteGroup) RouteFunc

func (group *RouteGroup) RouteFunc(route string, f func(http.ResponseWriter, *http.Request))

RouteFunc adds a route that is handled by a function to the group.

func (*RouteGroup) Use

func (group *RouteGroup) Use(middleware Middleware)

Use adds a middleware that is used for all routes in the router. Middlewares are applied in the same order `Use` is called.

Jump to

Keyboard shortcuts

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