router

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package router wraps the standard library's net/http.ServeMux (Go 1.22+ method+path patterns) with go-pkgz/routegroup for nestable groups and per-group middleware, and bridges the typed rest.HandlerFunc into the mux.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Middleware

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

Middleware is standard net/http middleware.

type Router

type Router struct {
	*routegroup.Bundle
	// contains filtered or unexported fields
}

Router is a thin wrapper over routegroup.Bundle that additionally knows how to mount typed rest.HandlerFunc handlers. The zero value is not usable; use New.

func New

func New(appMids ...rest.MidFunc) *Router

New creates a Router backed by a fresh ServeMux. appMids are applied to every handler registered via HandleApp (e.g. error mapping, auth), outermost first.

func (*Router) HandleApp

func (r *Router) HandleApp(pattern string, h rest.HandlerFunc, mids ...rest.MidFunc)

HandleApp registers a typed rest.HandlerFunc. The router's appMids plus any per-route mids are applied, and the result is adapted to http and encoded via rest.Respond.

func (*Router) Mount

func (r *Router) Mount(pattern string) *Router

Mount returns a sub-router rooted at pattern.

func (*Router) Route

func (r *Router) Route(fn func(*Router))

Route registers nested routes via a callback that receives a sub-router.

func (*Router) With

func (r *Router) With(mws ...Middleware) *Router

With returns a sub-router with the given net/http middleware applied.

Jump to

Keyboard shortcuts

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