router

package
v0.50.0 Latest Latest
Warning

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

Go to latest
Published: May 13, 2024 License: Apache-2.0 Imports: 3 Imported by: 1

Documentation

Overview

Package router implements a router of the http handler.

Index

Constants

This section is empty.

Variables

DefaultRouter is the default global router.

Functions

This section is empty.

Types

type Router

type Router struct {
	// Middlewares is used to manage the middlewares and takes effect
	// before routing the request.
	Middlewares *middleware.Manager

	// Router is used to manage the routes.
	Router http.Handler
}

Router is a http router that manages all the http middlewares uniformly.

func NewDefaultRouter added in v0.9.0

func NewDefaultRouter(router http.Handler) *Router

NewDefaultRouter is the same as NewRouter, but also adds the default middlewares, that's middleware.DefaultMiddlewares.

func NewRouter

func NewRouter(router http.Handler) *Router

NewRouter returns a new Router with the next router handler.

func (*Router) ServeHTTP

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

ServeHTTP implements the interface http.Handler.

func (*Router) Use

func (r *Router) Use(ms ...middleware.Middleware) *Router

Use appends a set of middlewares into the middleware manager.

func (*Router) UseFunc added in v0.43.0

func (r *Router) UseFunc(ms ...middleware.MiddlewareFunc) *Router

UseFunc appends a set of function middlewares into the middleware manager.

Directories

Path Synopsis
Package action implements a router based on the action service.
Package action implements a router based on the action service.
Package ruler implements a route manager based on the ruler.
Package ruler implements a route manager based on the ruler.

Jump to

Keyboard shortcuts

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