router

package
v0.0.0-...-7bdb5c7 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2020 License: MPL-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init(env *Env) *mux.Router

Init returns pointer to the router.

Types

type Env

type Env struct {
	// contains filtered or unexported fields
}

Env is a struct that carries environment data for request handlers.

func NewEnv

func NewEnv(logr *log.Logger, dbi *dbi.DBI) *Env

NewEnv returns pointer to a newly created Env instance.

type Handler

type Handler struct {
	E *Env
	F View
}

Handler implements http.Handler interface. It is useful because it can carry environment data.

func NewHandler

func NewHandler(env *Env, fun View) *Handler

NewHandler returns pointer to a newly created Handler instance.

func (*Handler) ServeHTTP

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

type View

type View func(http.ResponseWriter, *http.Request, *Env) error

View is a function type used by the Handler to handle requests that need access to data stored in Env.

Jump to

Keyboard shortcuts

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