httplib

package
v0.1.0-alpha.6 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2016 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package httplib implements common utility functions for writing classic HTTP handlers

Index

Constants

View Source
const StatusTooManyRequests = 429

Variables

This section is empty.

Functions

func ConvertResponse

func ConvertResponse(re *roundtrip.Response, err error) (*roundtrip.Response, error)

ConvertResponse converts http error to internal error type based on HTTP response code and HTTP body contents

func InsecureSetDevmodeHeaders

func InsecureSetDevmodeHeaders(w http.ResponseWriter)

InsecureSetDevmodeHeaders allows cross-origin requests, used in dev mode only

func MakeHandler

func MakeHandler(fn HandlerFunc) httprouter.Handle

MakeHandler returns a new httprouter.Handle func from a handler func

func ReadJSON

func ReadJSON(r *http.Request, val interface{}) error

ReadJSON reads HTTP json request and unmarshals it into passed interface{} obj

func ReplyError

func ReplyError(w http.ResponseWriter, err error)

ReplyError sets up http error response and writes it to writer w

Types

type HandlerFunc

type HandlerFunc func(w http.ResponseWriter, r *http.Request, p httprouter.Params) (interface{}, error)

HandlerFunc specifies HTTP handler function that returns error

Jump to

Keyboard shortcuts

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