Categorygithub.com/razonyang/fastrouter
modulepackage
0.1.0
Repository: https://github.com/razonyang/fastrouter.git
Documentation: pkg.go.dev

# README

FastRouter

FastRouter is a fast, flexible HTTP router written in Go.

FastRouter contains some customizable options, such as TrailingSlashesPolicy, PanicHandler, OptionsHandler, MethodNotAllowedHandler, NotFoundHandler and so on.

FastRouter also provides some useful features, such as grouping and middleware.

GoDoc Build Status Go Report Card Coverage Status

Features

Fast: See Go Web Framework Benchmark

Flexible: FastRouter provides some customizable options for you:

  • TrailingSlashesPolicy:
    • IgnoreTrailingSlashes: ignore trailing slashes.
    • AppendTrailingSlashes: append trailing slashes and redirect if request path is not end with '/'.
    • RemoveTrailingSlashes: remove trailing slashes and redirect if request path is end with '/'.
    • StrictTrailingSlashes: remove or append trailing slashes according to corresponding pattern.
  • PanicHandler
  • OptionsHandler
  • MethodNotAllowedHandler
  • NotFoundHandler

Compatible: FastRouter is an implementation of http.Handler, so it is compatible with third-party packages.

Middleware: Middleware is a chaining tool for chaining http.Handler, see Middleware.

Grouping: Grouping is an useful feature of FastRouter, it allows to nest and specify middleware of group, see Grouping.

Documentation

See Documentation for details.

Examples

See Examples for details.

# Functions

New returns a new Router with the default parser via NewWithParser.
NewParser returns a new parser via NewParserWithReg with the defaultParserRegexp.
NewParserWithReg returns a new parser with the given regexp.
NewWithParser returns a new Router with the given parser.
Params returns the parameters of the request path.

# Constants

append trailing slashes and redirect if request path is not end with '/'.
ignore trailing slashes.
remove trailing slashes and redirect if request path is end with '/'.
remove or append trailing slashes according to corresponding pattern.

# Structs

ParamsKey is an empty struct, it is the second parameter of context.WithValue for storing the request parameters.
Parser is the default pattern parser which implements ParserInterface.
Router is an implementation of http.Handler for handling HTTP requests.

# Interfaces

ParserInterface defines a Parse method for parsing pattern.

# Type aliases

Middleware is a chaining tool for chaining http.Handler.