Documentation ¶
Index ¶
- func ParseJsonBody(r io.ReadCloser, data interface{}) porterr.IError
- func ResponseErrorStrategy(response *http.Response) error
- func Send(writer http.ResponseWriter, response *JsonResponse)
- func SendJson(writer http.ResponseWriter, httpCode int, data interface{})
- func SendRawJson(writer http.ResponseWriter, httpCode int, data json.RawMessage)
- type HttpCodeMap
- type JsonResponse
- type Meta
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseJsonBody ¶
func ParseJsonBody(r io.ReadCloser, data interface{}) porterr.IError
ParseJsonBody Read json data from request body
func ResponseErrorStrategy ¶ added in v0.7.4
ResponseErrorStrategy Default response strategy
func SendJson ¶
func SendJson(writer http.ResponseWriter, httpCode int, data interface{})
SendJson Sent json into http writer
func SendRawJson ¶ added in v0.8.4
func SendRawJson(writer http.ResponseWriter, httpCode int, data json.RawMessage)
SendRawJson send raw JSON
Types ¶
type JsonResponse ¶
type JsonResponse struct { // HTTP code HttpCode int `json:"-"` // Message information Message interface{} `json:"message,omitempty"` // Body Data interface{} `json:"data,omitempty"` // Meta information Meta interface{} `json:"meta,omitempty"` // Error information Error interface{} `json:"error,omitempty"` }
JsonResponse Json response struct
func NewErrorJsonResponse ¶
func NewErrorJsonResponse(e porterr.IError) *JsonResponse
NewErrorJsonResponse New Json Response with error
func NewOkJsonResponse ¶
func NewOkJsonResponse(message interface{}, data interface{}, meta interface{}) *JsonResponse
NewOkJsonResponse New Json Response without error
Click to show internal directories.
Click to hide internal directories.