cockroach: github.com/cockroachdb/cockroach/pkg/util/httputil Index | Files

package httputil

import "github.com/cockroachdb/cockroach/pkg/util/httputil"

Index

Package Files

http.go

Constants

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"
)

func GetJSON Uses

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

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

func PostJSON Uses

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

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

func PostJSONWithRequest Uses

func PostJSONWithRequest(
    httpClient http.Client, path string, request, response protoutil.Message,
) (*http.Response, error)

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

The response is returned to the caller, though its body will have been closed.

Package httputil imports 7 packages (graph) and is imported by 12 packages. Updated 2019-07-09. Refresh now. Tools for package owners.