middleware

package
v0.0.0-...-33a8802 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

type Context api.Context

Context is the placeholder for the common API context struct.

func (Context) Authenticate

func (apiContext Context) Authenticate(next http.Handler) http.Handler

Authenticate reads the authentication headers and attempts to authenticate the user. If no credentials are specified, the session is continued assuming an anonimus user. If the credentials are wrong, then a HTTP 401 error response is returned.

func (Context) DisallowAnon

func (apiContext Context) DisallowAnon(h http.Handler) http.Handler

DisallowAnon does not allow anonymous users to access the page

func (Context) DisallowAuth

func (apiContext Context) DisallowAuth(h http.Handler) http.Handler

DisallowAuth does not allow authenticated users to access the page

func (Context) HideFromAnon

func (apiContext Context) HideFromAnon(h http.Handler) http.Handler

HideFromAnon returns a HTTP 404 Not Found response for anonymous users.

func (Context) Inject

func (apiContext Context) Inject(h http.Handler) http.Handler

Inject takes a database connection from the connection pool (performed by Copy) and injects it into the request context.

func (Context) Logging

func (apiContext Context) Logging(h http.Handler) http.Handler

Logging records all incoming requests to the log. Only in debug trace mode.

func (Context) PanicRecovery

func (apiContext Context) PanicRecovery(h http.Handler) http.Handler

PanicRecovery catches all panics that happen downstream, returns an HTTP 500 Internal Server Error and log the state without crashing the server.

func (Context) RequestID

func (apiContext Context) RequestID(h http.Handler) http.Handler

RequestID adds a request ID to the context so that we can track errors based on it.

type StorageContext

type StorageContext storage.Context

StorageContext is the alias for the storage context struct.

func (StorageContext) Inject

func (storageContext StorageContext) Inject(h http.Handler) http.Handler

Inject takes a database connection from the connection pool (performed by Copy) and injects it into the request context.

Jump to

Keyboard shortcuts

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