Documentation ¶
Index ¶
- Constants
- func BadRequest(w http.ResponseWriter)
- func CreateBoundLogger(logger log.Interface) func(r *http.Request) log.Interface
- func Error(w http.ResponseWriter, statusCode int, errMessage string)
- func InternalServerError(w http.ResponseWriter)
- func NotAllowed(w http.ResponseWriter)
- func NotFound(w http.ResponseWriter)
- func NotLoggedInError(w http.ResponseWriter)
- func OK(w http.ResponseWriter, data interface{})
- func OKWithResponseCode(w http.ResponseWriter, statusCode int, data interface{})
- func OKWithoutContent(w http.ResponseWriter)
- func Redirect(w http.ResponseWriter, r *http.Request, url string, code int)
- type ErrorData
- type ErrorResponse
- type SuccessResponse
Constants ¶
View Source
const NotLoggedInErrorText = "You are not logged in"
Variables ¶
This section is empty.
Functions ¶
func BadRequest ¶
func BadRequest(w http.ResponseWriter)
BadRequest replies to the request with an HTTP 404 Given Param is not valid
func CreateBoundLogger ¶
CreateBoundLogger create error response generator Method will log error
func Error ¶
func Error(w http.ResponseWriter, statusCode int, errMessage string)
Error basic function to send any type of Error
func InternalServerError ¶
func InternalServerError(w http.ResponseWriter)
InternalServerError replies to the request with an HTTP 500 Internal Server Error error
func NotAllowed ¶
func NotAllowed(w http.ResponseWriter)
NotAllowed replies to the request with an HTTP 405 Method Not Allowed
func NotFound ¶
func NotFound(w http.ResponseWriter)
NotFound replies to the request with an HTTP 404 Not Found error
func NotLoggedInError ¶
func NotLoggedInError(w http.ResponseWriter)
func OK ¶
func OK(w http.ResponseWriter, data interface{})
OK response with 200 status code and data in payload
func OKWithResponseCode ¶
func OKWithResponseCode(w http.ResponseWriter, statusCode int, data interface{})
OKWithResponseCode response with 2xx status code
func OKWithoutContent ¶
func OKWithoutContent(w http.ResponseWriter)
OKWithoutContent response with 204 status code
Types ¶
type ErrorData ¶
type ErrorData struct { Code int `json:"code"` Message string `json:"message,omitempty"` Data interface{} `json:"data,omitempty"` }
ErrorData represents error in error response
type ErrorResponse ¶
type ErrorResponse struct {
ErrorData ErrorData `json:"error"`
}
ErrorResponse represents error response
type SuccessResponse ¶
type SuccessResponse struct {
Data interface{} `json:"data"`
}
Click to show internal directories.
Click to hide internal directories.