httputil

package
v0.0.0-...-4f9c864 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2017 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// AcceptHeader is the canonical header name for accept.
	AcceptHeader = "Accept"
	// AcceptEncodingHeader is the canonical header name for accept encoding.
	AcceptEncodingHeader = "Accept-Encoding"
	// ContentEncodingHeader is the canonical header name for content type.
	ContentEncodingHeader = "Content-Encoding"
	// ContentTypeHeader is the canonical header name for content type.
	ContentTypeHeader = "Content-Type"
	// JSONContentType is the JSON content type.
	JSONContentType = "application/json"
	// AltJSONContentType is the alternate JSON content type.
	AltJSONContentType = "application/x-json"
	// ProtoContentType is the protobuf content type.
	ProtoContentType = "application/x-protobuf"
	// AltProtoContentType is the alternate protobuf content type.
	AltProtoContentType = "application/x-google-protobuf"
	// PlaintextContentType is the plaintext content type.
	PlaintextContentType = "text/plain"
	// GzipEncoding is the gzip encoding.
	GzipEncoding = "gzip"
)

Variables

This section is empty.

Functions

func GetJSON

func GetJSON(httpClient http.Client, path string, response proto.Message) error

GetJSON uses the supplied client to GET the URL specified by the parameters and unmarshals the result into response.

func PostJSON

func PostJSON(httpClient http.Client, path string, request, response proto.Message) error

PostJSON uses the supplied client to POST request to the URL specified by the parameters and unmarshals the result into response.

func StreamJSON

func StreamJSON(
	httpClient http.Client,
	path string,
	request proto.Message,
	dest proto.Message,
	callback func(proto.Message),
) error

StreamJSON uses the supplied client to POST the given proto request as JSON to the supplied streaming grpc-gw endpoint; the response type serves only to create the values passed to the callback (which is invoked for every message in the stream with a value of the supplied response type masqueraded as an interface).

Types

This section is empty.

Jump to

Keyboard shortcuts

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