router

package
v2.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

package router provides an interface for routing HTTP requests to handlers

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MatchingScheme

type MatchingScheme int
const (
	MatchExactPath  MatchingScheme = 0
	MatchHostname   MatchingScheme = 1
	MatchPathPrefix MatchingScheme = 2

	DefaultMatchingScheme MatchingScheme = MatchHostname | MatchPathPrefix
)

type Router

type Router interface {
	// ServeHTTP services the provided HTTP Request and write the Response
	ServeHTTP(http.ResponseWriter, *http.Request)
	// RegisterRoute registers a handler for the provided path/host/method(s)
	// If hosts is nil, the route uses global-routing instead of host-based
	// If methods is nil, the route is applicable to GET and HEAD requests
	// If methods includes GET but not HEAD, HEAD is automatically included
	RegisterRoute(path string, hosts, methods []string, matchPrefix bool,
		handler http.Handler) error
	// Handler returns the handler matching the method/host/path in the Request
	Handler(*http.Request) http.Handler
	// SetMatchingScheme specifies the ways the Router matches requests
	SetMatchingScheme(MatchingScheme)
}

Directories

Path Synopsis
package lm represents a simple Longest Match router
package lm represents a simple Longest Match router
package route provides a Route data structure for Request Routing
package route provides a Route data structure for Request Routing

Jump to

Keyboard shortcuts

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