mw

package
v0.0.0-...-403b7d6 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package mw defines various pieces of middleware that conform to the http.Handler and the httprouter.Handle interfaces.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoKey     = errors.New("HEYAPPLE_CSRF_KEY environment variable not found. Using insecure default value. Do NOT run this in a production environment!")
	ErrNoSecure  = errors.New("HEYAPPLE_CSRF_SECURE environment variable not found. CSRF cookies will be sent over insecure connections. Do NOT run this in a production environment!")
	ErrNotSecure = errors.New("HEYAPPLE_CSRF_SECURE is set to 'false'. CSRF cookies will be sent over insecure connections. Do NOT run this in a production environment!")
)

Functions

func CSRF

func CSRF(env *handler.Environment, next http.Handler) http.Handler

func Options

func Options(w http.ResponseWriter, r *http.Request)

Options is a middleware that tells clients about CORS capabilities.

Types

type Func

func Anon

func Anon(env *handler.Environment, target string) Func

Anon is a middleware that prevents logged-in users from accessing a resource.

func Auth

func Auth(env *handler.Environment, target string) Func

Auth is a middleware that grants only logged-in users access to a resource.

func JSON

func JSON() Func

JSON is a middleware to identify response bodies as JSON data.

Jump to

Keyboard shortcuts

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