handlers

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2017 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateUserHandler

func CreateUserHandler(env *env.Env, w http.ResponseWriter, req *http.Request) error

CreateUserHandler creates a user in the database

func PathMatch

func PathMatch(env *env.Env, rtr *mux.Router) *mux.Router

PathMatch is a way of organizing routing to handlers (versioning as well)

Types

type Error

type Error interface {
	error
	Status() int
}

Error represents a handler error. It provides methods for a HTTP status code and embeds the built-in error interface.

type HTTPStatusError

type HTTPStatusError struct {
	Code int
	Err  error
}

HTTPStatusError represents an error with an associated HTTP status code.

func (HTTPStatusError) Error

func (hse HTTPStatusError) Error() string

Allows HTTPStatusError to satisfy the error interface.

func (HTTPStatusError) Status

func (hse HTTPStatusError) Status() int

Status Returns an HTTP status code.

type Handler

type Handler struct {
	Env *env.Env
	H   func(e *env.Env, w http.ResponseWriter, r *http.Request) error
}

The Handler struct that takes a configured Env and a function matching our useful signature.

func (Handler) ServeHTTP

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

ServeHTTP allows Handler type to satisfy the http.Handler interface

Jump to

Keyboard shortcuts

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