Documentation ¶
Index ¶
- func Accepted(w http.ResponseWriter, v any)
- func BadRequest(w http.ResponseWriter, code, message string, errs ...string)
- func Created(w http.ResponseWriter, v any)
- func Forbidden(w http.ResponseWriter, code, message string, errs ...string)
- func HTML(w http.ResponseWriter, status int, name string, v any)
- func InternalServerError(w http.ResponseWriter, code, message string, errs ...string)
- func JSON(w http.ResponseWriter, status int, v any)
- func NewErr(w http.ResponseWriter, err *ErrResponse)
- func NoContent(w http.ResponseWriter)
- func NotFound(w http.ResponseWriter, code, message string, errs ...string)
- func OK(w http.ResponseWriter, v any)
- func PageOf(w http.ResponseWriter, v any, page, size, total int)
- func PartialContent(w http.ResponseWriter, v any)
- func Unauthorized(w http.ResponseWriter, code, message string, errs ...string)
- func UnprocessableEntity(w http.ResponseWriter, code, message string, errs ...string)
- type ErrResponse
- type M
- type Meta
- type Page
- type Response
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Accepted ¶
func Accepted(w http.ResponseWriter, v any)
func BadRequest ¶
func BadRequest(w http.ResponseWriter, code, message string, errs ...string)
func Created ¶
func Created(w http.ResponseWriter, v any)
func InternalServerError ¶
func InternalServerError(w http.ResponseWriter, code, message string, errs ...string)
func NewErr ¶
func NewErr(w http.ResponseWriter, err *ErrResponse)
func NoContent ¶
func NoContent(w http.ResponseWriter)
func OK ¶
func OK(w http.ResponseWriter, v any)
func PartialContent ¶
func PartialContent(w http.ResponseWriter, v any)
func Unauthorized ¶
func Unauthorized(w http.ResponseWriter, code, message string, errs ...string)
func UnprocessableEntity ¶
func UnprocessableEntity(w http.ResponseWriter, code, message string, errs ...string)
Types ¶
type ErrResponse ¶
type ErrResponse struct { Error errDTO `json:"error"` Details []errDTO `json:"details,omitempty"` }
func NewErrResponse ¶
func NewErrResponse(status int, code, message string, errs ...string) *ErrResponse
type M ¶
M is a convenience alias for quickly building a map structure that is going out to a responder. Just a short-hand.
type Page ¶
type Page struct { Page int `json:"page,omitempty"` Size int `json:"size,omitempty"` Total int `json:"total,omitempty"` }
Based on: https://github.com/microsoft/api-guidelines/blob/vNext/Guidelines.md https://jsonapi.org/format/#document-top-level https://jsonapi.org/profiles/ethanresnick/cursor-pagination https://github.com/interagent/http-api-design/tree/master/en https://geemus.gitbooks.io/http-api-design/content/en/responses/return-appropriate-status-codes.html
Click to show internal directories.
Click to hide internal directories.