Documentation ¶
Index ¶
- Variables
- func ErrorResponse(w http.ResponseWriter, r *http.Request, code int, error error, msg string)
- func JsonResponse(w http.ResponseWriter, data interface{})
- func Logger(next http.Handler) http.Handler
- func NotFound(w http.ResponseWriter, _ *http.Request)
- func OkResponse(w http.ResponseWriter)
- func ReadBody(w http.ResponseWriter, r *http.Request, str interface{}) error
- func RenderJSON(w http.ResponseWriter, code int, data interface{})
- type HttpError
- type Server
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrEmptyRequest = errors.New("empty request")
View Source
var ErrNotPointer = errors.New("not pointer provided")
Functions ¶
func ErrorResponse ¶
JsonError - write a HttpError structure as response.
func JsonResponse ¶
func JsonResponse(w http.ResponseWriter, data interface{})
JsonResponse - write a response with application/json Content-Type header.
func NotFound ¶
func NotFound(w http.ResponseWriter, _ *http.Request)
NotFound - return a error page for not found
func OkResponse ¶ added in v0.0.7
func OkResponse(w http.ResponseWriter)
OKResponse - write a OK response with application/json Content-Type header.
func ReadBody ¶
func ReadBody(w http.ResponseWriter, r *http.Request, str interface{}) error
Read body from request and trying to unmarshal to provided struct.
func RenderJSON ¶
func RenderJSON(w http.ResponseWriter, code int, data interface{})
RenderJSON sends data as json.
Types ¶
Click to show internal directories.
Click to hide internal directories.