http

package
v1.2.4 Latest Latest
Warning

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

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

Documentation

Overview

Package http provides utility functions for HTTP servers and clients.

Index

Constants

View Source
const MaxBodySize int64 = 1048576

MaxBodySize is the maximum number of bytes that ParseHTTPBody reads from an http.Request.Body.

Variables

This section is empty.

Functions

func ParseHTTPBody

func ParseHTTPBody(r *http.Request, v interface{}) (int, error)

ParseHTTPBody reads a JSON-encoded body from a http.Request and unmarshals it into the provided object.

func WriteHTTP

func WriteHTTP(w http.ResponseWriter, httpStatus int, v interface{})

WriteHTTP writes a JSON-encoded object to a http.ResponseWriter, as well as a HTTP status code.

func WriteHTTPError

func WriteHTTPError(w http.ResponseWriter, httpStatus int, err error)

WriteHTTPError writes an error, wrapped in the Message field of a JSON-encoded object to a http.ResponseWriter, as well as a HTTP status code. If the status code is 0, handleError tries to guess the proper HTTP status code from the error type.

Types

This section is empty.

Jump to

Keyboard shortcuts

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