httproutermiddleware

package module
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2022 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	BasePath string
	Groups   Groups
	Routes   Routes
	Pipeline Pipeline
}

type Group

type Group struct {
	// Path for the group
	Path string
	// Routes in the group
	Routes []Route
	// Set of middlewares to be applied to the routes. If a route already has its pipeline, group's pipeline will wrap it
	Pipeline Pipeline
}

Group struct represents a group of routes. Pipeline middlewares will be applied to all routes in the group.

type Groups

type Groups []Group

type Middleware

type Middleware func(next httprouter.Handle) httprouter.Handle

Middleware wraps the next handler.

type Pipeline

type Pipeline []Middleware

Pipeline the pipeline of middlawares.

type Route

type Route struct {
	// Path
	Path string
	// Handle function
	Handler httprouter.Handle
	// Method verb
	Method string
	// Set of middlewares to be applied to the routes
	Pipeline Pipeline
}

Route struct for representing a route.

type Router

type Router struct {
	*httprouter.Router
}

Router wrapper for httprouter.Router.

func New

func New(r *httprouter.Router, c *Config) *Router

func NewDefaultRouter

func NewDefaultRouter(c *Config) *Router

func (*Router) Apply

func (r *Router) Apply(c *Config)

type Routes

type Routes []Route

Jump to

Keyboard shortcuts

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