httputil

package module
v0.0.0-...-1ca62de Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2018 License: BSD-3-Clause Imports: 9 Imported by: 3

README

httputil: HTTP helpers

Collection of various functions to work on HTTP resources.

GoDoc

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidContentType represents an unsupported content type error.
	ErrInvalidContentType = errors.New("invalid content type")
	// ErrInvalidInterface represents an invalid interface error.
	ErrInvalidInterface = errors.New("invalid interface")
)

Functions

func BindJSON

func BindJSON(v interface{}, out interface{}) error

BindJSON binds JSON data received from request or response to an interface.

func GetContentType

func GetContentType(v interface{}) (string, error)

GetContentType returns the HTTP 'Content-Type' header value.

func NewClient

func NewClient(timeout time.Duration, dualStack, skipVerify bool) *http.Client

NewClient creates a new HTTP client instance.

func WriteJSON

func WriteJSON(rw http.ResponseWriter, v interface{}, code int) error

WriteJSON marshals an interface to JSON data and writes it on an HTTP response writer.

Types

This section is empty.

Jump to

Keyboard shortcuts

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