httputil

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2019 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

func AdaptMiddleware

func AdaptMiddleware(w func(http.Handler) http.Handler) func(handle httprouter.Handle) httprouter.Handle

Wraps a normal http.Handler middleware and wraps it so it can be used with httprouter.Handle functions.

func ExtractAndCall

func ExtractAndCall(target interface{}, w http.ResponseWriter, r *http.Request, params httprouter.Params, handler func() (interface{}, error))

func ExtractAndCallWithBody added in v1.2.8

func ExtractAndCallWithBody(
	target interface{},
	body interface{},
	w http.ResponseWriter,
	r *http.Request,
	params httprouter.Params,
	handler func() (interface{}, error))

func ExtractParameters

func ExtractParameters(target interface{}, r *http.Request, params httprouter.Params) error

func WriteBody

func WriteBody(writer http.ResponseWriter, status int, contentType string, content []byte, headers ...Header) error

func WriteError

func WriteError(writer http.ResponseWriter, status int, err error) error

func WriteGenericError

func WriteGenericError(w http.ResponseWriter, err error)

func WriteJSON

func WriteJSON(w http.ResponseWriter, status int, value interface{}, headers ...Header) error

func WriteResponseValue

func WriteResponseValue(w http.ResponseWriter, value interface{}, err error, headers ...Header)

func WriteResponseValueStatus

func WriteResponseValueStatus(w http.ResponseWriter, statusCode int, value interface{}, err error, headers ...Header)

Types

type ErrorResponse

type ErrorResponse struct {
	Status int    `json:"status"`
	Error  string `json:"error"`
}
type Header struct {
	Key     string
	Value   string
	Replace bool
}

Jump to

Keyboard shortcuts

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