middleware

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Wrap

func Wrap(next http.Handler, fn AuthFunc) http.Handler

Wrap wraps an http.Handler with an AuthFunc. Requests that fail auth get a 401. Requests with ?token= in the query string are redirected to strip the token after the cookie is set.

Types

type AuthFunc

type AuthFunc func(w http.ResponseWriter, r *http.Request) bool

AuthFunc decides if a request is authorized.

func TokenAuth

func TokenAuth() (string, AuthFunc)

TokenAuth returns an AuthFunc that validates requests using a token. On first visit with ?token=... in the URL, sets a cookie. Subsequent requests are authenticated via the cookie.

Jump to

Keyboard shortcuts

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