middleware

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2022 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Error

func Error(w http.ResponseWriter, status int)

Error is a shorthand for writing standard error messages to the response writer

func Logged

func Logged(h func(w http.ResponseWriter, r *http.Request)) http.Handler

Logged logs the details of the request and response

func WithOptions

func WithOptions(h http.HandlerFunc, options HandlerOptions) http.Handler

Types

type AuthenticationOptions

type AuthenticationOptions struct {
	Required bool
	// ValidationFunc should return true or false based on whether the request is authenticated
	ValidationFunc func(*http.Request) bool
}

type CorsOptions

type CorsOptions struct {
	Enabled      bool
	AllowHeaders []string
	AllowOrigins []string
	AllowMethods []string
}

type HandlerOptions

type HandlerOptions struct {
	Methods        []string
	Cors           CorsOptions
	Authentication AuthenticationOptions
}

Jump to

Keyboard shortcuts

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