handler

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Factory

type Factory struct {
	Db                    *database.Database
	Config                configuration.Configuration
	AssumeJSONContentType bool
}

Factory stores repeated requirements for constructing handlers

func (Factory) Handler

func (factory Factory) Handler(handler Func, options ...Option) Handler

Handler returns a Handler from a HandlerFunc with database and configuration

type Func

type Func func(
	db *database.Database,
	cur core.Current,
	vars map[string]string,
	w http.ResponseWriter,
	r *http.Request,
) error

Func is the dwn-specific signature for handler functions

type Handler

type Handler struct {
	Handler Func
	// contains filtered or unexported fields
}

Handler is a wrapper struct for giving HandlerFunc functionality

func (Handler) ServeHTTP

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

ServeHTTP allows the module Handler to match the interface requirements for the standard library Handler while adding application specific context.

type Option

type Option int

Option is a type for option constants

const (
	OptionAllowCORS Option = iota
	OptionAllowAnonymous
	OptionVaultPINRequired
)

type Options

type Options []Option

Options is a type representing multiple options and providing a Contains method.

func (Options) Contains

func (options Options) Contains(option Option) bool

Contains returns whether an instance of Options contains a specific Option.

type Status404Handler added in v0.4.0

type Status404Handler string

func (Status404Handler) ServeHTTP added in v0.4.0

func (h Status404Handler) ServeHTTP(w http.ResponseWriter, req *http.Request)

Jump to

Keyboard shortcuts

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