authmw

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package authmw provides a shared HTTP middleware-wrapping helper for request-based authenticators (basic, github, hmac).

It is a dependency-free leaf package: the root http package imports basic/github/hmac to build handlers from config, so those adapter packages cannot import the root http package (or anything that does) without an import cycle. authmw has no such dependency, so any of them can import it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Wrap

func Wrap(authenticate AuthRequestFunc, next http.Handler, onError func(w http.ResponseWriter, r *http.Request, err error)) http.Handler

Wrap adapts authenticate into an http.Handler wrapping next: on each request it calls authenticate; on error, onError writes the response and the chain stops there; on success, next runs with the authenticated context.

Types

type AuthRequestFunc

type AuthRequestFunc func(r *http.Request) (context.Context, error)

AuthRequestFunc authenticates an HTTP request, returning an enriched context on success. A Handler's AuthRequest method satisfies this type.

Jump to

Keyboard shortcuts

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