Documentation ¶
Overview ¶
Package httpx helper functions for http operations
Index ¶
Constants ¶
View Source
const ( JSONContentType = "application/json; charset=utf-8" OctetStreamContentType = "application/octet-stream" )
content types
Variables ¶
This section is empty.
Functions ¶
func HandleResponseError ¶
HandleResponseError check response status code. If code is not 2xx, then error returned.
func IsCausedByContextCanceled ¶
IsCausedByContextCanceled to check if the err
func ResponseJSON ¶
func ResponseJSON(w http.ResponseWriter, obj interface{}) error
ResponseJSON reponse a object in JSON enconding
func WrapHandlerFunc ¶
func WrapHandlerFunc(f HandlerFunc) http.HandlerFunc
WrapHandlerFunc convert HandlerFunc to http.HandlerFunc
Types ¶
type HandlerFunc ¶
type HandlerFunc func(http.ResponseWriter, *http.Request) error
HandlerFunc like http.HandlerFunc, bu it returns an error. If the returned error is errorWithStatus type, errorWithStatus.status will be responded, otherwise http.StatusInternalServerError responded.
Click to show internal directories.
Click to hide internal directories.