http

package
v1.7.2 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckResponse

func CheckResponse(r *http.Response) error

CheckResponse checks the API response for errors, and returns them if present. A response is considered an error if it has a status code outside the 200 range. API error responses are expected to have either no response body, or a JSON response body that maps to ErrorResponse. Any other response body will be silently ignored.

func WrapWithError added in v1.6.0

func WrapWithError(f HandlerFuncWithErr, log kitlog.Logger) http.HandlerFunc

Types

type ErrorResponse

type ErrorResponse struct {
	Response *http.Response `json:",omitempty"`
	Body     []byte
}

An ErrorResponse reports errors caused by an API request.

func (*ErrorResponse) Error

func (r *ErrorResponse) Error() string

type HandlerFuncWithErr added in v1.6.0

type HandlerFuncWithErr func(w http.ResponseWriter, r *http.Request) error

type MiddlewareFunc added in v1.6.0

type MiddlewareFunc func(next http.Handler) http.Handler

func Authorize added in v1.6.0

func Authorize(headerName, wantHeader string) MiddlewareFunc

Authorize does a very simple header check against a wanted value it returns http.StatusUnauthorized if it's false

Directories

Path Synopsis
Package render implements template inheritance and exposes functions to render HTML.
Package render implements template inheritance and exposes functions to render HTML.

Jump to

Keyboard shortcuts

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