utils

package
v0.0.0-...-9933748 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2014 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExactGetHandler

func ExactGetHandler(h http.Handler) http.Handler

ExactGetHandler is like ExactHandler wrapped with a GetHandler

func ExactHandler

func ExactHandler(h http.Handler) http.Handler

ExactHandler returns a 404 if someone requests a subresource of the wrapped resource

func GetHandler

func GetHandler(h http.Handler) http.Handler

GetHandler makes sure the wrapped http.Handler only responds to GETs

func LoggingHandler

func LoggingHandler(h http.Handler) http.Handler

LoggingHandler is a simple middleware for logging requests

func Shift

func Shift(path string) (dir, left string)

Shift pulls the first directory out of the path and returns the remainder.

Types

type DirMux

type DirMux map[string]http.Handler

DirMux is an http.Handler that mimics a directory. It mutates an incoming requests URL.Path to properly namespace handlers. This way a handler can assume it has the root of its section. If you want the original URL use req.RequestURI (but don't modify it).

func (DirMux) ServeHTTP

func (d DirMux) ServeHTTP(w http.ResponseWriter, r *http.Request)

type MethodMux

type MethodMux map[string]http.Handler

MethodMux is an http.Handler muxer that keys off of the given HTTP request method

func (MethodMux) ServeHTTP

func (m MethodMux) ServeHTTP(w http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

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