Documentation ¶
Index ¶
- func IsRequestBodyTooLarge(err error) bool
- func ParseProtoReader(ctx context.Context, reader io.Reader, expectedSize, maxSize int, ...) error
- func RenderHTTPResponse(w http.ResponseWriter, v interface{}, t *template.Template, r *http.Request)
- func SerializeProtoResponse(w http.ResponseWriter, resp proto.Message, compression CompressionType) error
- func StreamWriteYAMLResponse(w http.ResponseWriter, iter chan interface{}, logger log.Logger)
- func WriteHTMLResponse(w http.ResponseWriter, message string)
- func WriteJSONResponse(w http.ResponseWriter, v interface{})
- func WriteTextResponse(w http.ResponseWriter, message string)
- func WriteYAMLResponse(w http.ResponseWriter, v interface{})
- type BasicAuth
- type CompressionType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsRequestBodyTooLarge ¶
IsRequestBodyTooLarge returns true if the error is "http: request body too large".
func ParseProtoReader ¶
func ParseProtoReader(ctx context.Context, reader io.Reader, expectedSize, maxSize int, req proto.Message, compression CompressionType) error
ParseProtoReader parses a compressed proto from an io.Reader.
func RenderHTTPResponse ¶
func RenderHTTPResponse(w http.ResponseWriter, v interface{}, t *template.Template, r *http.Request)
RenderHTTPResponse either responds with json or a rendered html page using the passed in template by checking the Accepts header
func SerializeProtoResponse ¶
func SerializeProtoResponse(w http.ResponseWriter, resp proto.Message, compression CompressionType) error
SerializeProtoResponse serializes a protobuf response into an HTTP response.
func StreamWriteYAMLResponse ¶
func StreamWriteYAMLResponse(w http.ResponseWriter, iter chan interface{}, logger log.Logger)
StreamWriteYAMLResponse stream writes data as http response
func WriteHTMLResponse ¶
func WriteHTMLResponse(w http.ResponseWriter, message string)
Sends message as text/html response with 200 status code.
func WriteJSONResponse ¶
func WriteJSONResponse(w http.ResponseWriter, v interface{})
WriteJSONResponse writes some JSON as a HTTP response.
func WriteTextResponse ¶
func WriteTextResponse(w http.ResponseWriter, message string)
Sends message as text/plain response with 200 status code.
func WriteYAMLResponse ¶
func WriteYAMLResponse(w http.ResponseWriter, v interface{})
WriteYAMLResponse writes some YAML as a HTTP response.
Types ¶
type BasicAuth ¶
type BasicAuth struct { Username string `yaml:"basic_auth_username"` Password string `yaml:"basic_auth_password"` }
BasicAuth configures basic authentication for HTTP clients.
type CompressionType ¶
type CompressionType int
CompressionType for encoding and decoding requests and responses.
const ( NoCompression CompressionType = iota RawSnappy )
Values for CompressionType