httputil

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2019 License: MIT Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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