httpx

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package httpx is the routing layer.

It is a thin shell over net/http: Middleware is the standard func(http.Handler) http.Handler, so every middleware written for the Go ecosystem works here unchanged.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Chain

func Chain(h http.Handler, mws ...Middleware) http.Handler

Chain composes middlewares. The first in the list is the outermost.

Types

type Middleware

type Middleware func(http.Handler) http.Handler

Middleware is the standard net/http signature. We do not invent our own type: that is what keeps the whole Go ecosystem compatible with the framework.

type Route

type Route struct {
	Name    string
	Method  string
	Pattern string
	Module  string
}

Route is metadata, used by `aru routes` and by the error page.

type Router

type Router struct {
	// contains filtered or unexported fields
}

Router is a thin shell over http.ServeMux, which since Go 1.22 already handles methods and path parameters. It exists for groups, per-group middleware and route metadata -- the metadata is what lets the CLI generate typed URL helpers and what the error page uses to show the matched route.

func NewRouter

func NewRouter() *Router

NewRouter returns an empty router.

func (*Router) Delete

func (r *Router) Delete(pattern string, h http.HandlerFunc, mws ...Middleware)

Delete registers a DELETE route.

func (*Router) ForModule

func (r *Router) ForModule(name string) *Router

ForModule returns a sub-router that tags its routes with the module name, so `aru routes` can group them. The Kernel calls it for each module.

func (*Router) Get

func (r *Router) Get(pattern string, h http.HandlerFunc, mws ...Middleware)

Get registers a GET route.

func (*Router) Group

func (r *Router) Group(prefix string, mws ...Middleware) *Router

Group returns a sub-router with the prefix appended and the middleware inherited. The route table is shared with the parent.

func (*Router) Patch

func (r *Router) Patch(pattern string, h http.HandlerFunc, mws ...Middleware)

Patch registers a PATCH route.

func (*Router) Post

func (r *Router) Post(pattern string, h http.HandlerFunc, mws ...Middleware)

Post registers a POST route.

func (*Router) Put

func (r *Router) Put(pattern string, h http.HandlerFunc, mws ...Middleware)

Put registers a PUT route.

func (*Router) Routes

func (r *Router) Routes() []Route

Routes returns the registered routes, in registration order.

func (*Router) ServeHTTP

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

ServeHTTP dispatches to the underlying mux.

Directories

Path Synopsis
Package middleware holds the mandatory request pipeline.
Package middleware holds the mandatory request pipeline.

Jump to

Keyboard shortcuts

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