htp

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2016 License: Apache-2.0 Imports: 3 Imported by: 6

Documentation

Overview

Package htp contains utility functionality for writing HTTP handlers and building HTTP servers

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Error

func Error(w http.ResponseWriter, code int, fmtStr string, vars ...interface{})

Error is a convenience function for http.Error, but it allows you to specify the error string in a format string

func MatchesMethod

func MatchesMethod(r *http.Request, m Method) bool

MatchesMethod returns whether or not the method in r is the same as m

func MethodMux

func MethodMux(m map[Method]http.Handler) http.Handler

MethodMux returns an http.Handler that routes to the correct handler based on the request method as defined in m

func SplitPath

func SplitPath(r *http.Request) []string

SplitPath returns a slice of path elements in r. It returns nil if r.URL.Path is empty or "/"

Types

type Method

type Method string

Method is the type for the incoming HTTP Method

const (
	// Get is the constant for the HTTP GET method
	Get Method = "GET"
	// Post is the constant for the HTTP POST method
	Post Method = "POST"
	// Put is the constant for the HTTP PUT method
	Put Method = "PUT"
	// Delete is the constant for the HTTP DELETE method
	Delete Method = "DELETE"
	// Head is the constant for the HTTP HEAD method
	Head Method = "HEAD"
	// Options is the constant for the HTTP OPTIONS method
	Options Method = "OPTIONS"
)

func (Method) String

func (m Method) String() string

String is the fmt.Stringer interface implementation

Jump to

Keyboard shortcuts

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