Documentation ¶
Overview ¶
Package path implements HTTP responses struct features and functions
Index ¶
- func FromGRPCError(err *status.Status, w http.ResponseWriter)
- func InternalServerError(w http.ResponseWriter)
- func NewUserResponse(u *models.UserResponse, w http.ResponseWriter)
- func NotFound(w http.ResponseWriter)
- func Respond(w http.ResponseWriter, statusCode int, responseBody []byte)
- func RespondBadRequest(w http.ResponseWriter, msg string)
- func RespondConflict(w http.ResponseWriter, msg string)
- func RespondCreated(w http.ResponseWriter)
- func RespondNotAuthorized(w http.ResponseWriter, msg string)
- func RespondNotFound(w http.ResponseWriter)
- func RespondOk(w http.ResponseWriter)
- func User(w http.ResponseWriter, u models.UserResponse)
- type Builder
- func (rb *Builder) AddHeader(key, val string) *Builder
- func (rb *Builder) Respond()
- func (rb *Builder) SetError(err error) *Builder
- func (rb *Builder) SetMessage(msg string) *Builder
- func (rb *Builder) SetReason(reason string) *Builder
- func (rb *Builder) SetResponseCode(statusCode int) *Builder
- func (rb *Builder) SetWriter(w http.ResponseWriter) *Builder
- type ErrResponse
- type Error
- type ErrorResponse
- func NewAccessDeniedErrorResponse() *ErrorResponse
- func NewBadRequestErrorResponse(msg string) *ErrorResponse
- func NewConflictResponse(msg string) *ErrorResponse
- func NewErrorResponse(statusCode int32, reason, message string) *ErrorResponse
- func NewInternalServerErrorErrorResponse() *ErrorResponse
- func NewServiceUnavailableErrorResponse() *ErrorResponse
- func NewUnauthorizedErrorResponse(msg string) *ErrorResponse
- type NotFoundResponse
- type StatusError
- type UnauthorizedResponse
- type UserResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FromGRPCError ¶
func FromGRPCError(err *status.Status, w http.ResponseWriter)
func InternalServerError ¶
func InternalServerError(w http.ResponseWriter)
func NewUserResponse ¶
func NewUserResponse(u *models.UserResponse, w http.ResponseWriter)
func NotFound ¶
func NotFound(w http.ResponseWriter)
func RespondBadRequest ¶
func RespondBadRequest(w http.ResponseWriter, msg string)
func RespondConflict ¶
func RespondConflict(w http.ResponseWriter, msg string)
func RespondCreated ¶
func RespondCreated(w http.ResponseWriter)
func RespondNotAuthorized ¶
func RespondNotAuthorized(w http.ResponseWriter, msg string)
func RespondNotFound ¶
func RespondNotFound(w http.ResponseWriter)
func RespondOk ¶
func RespondOk(w http.ResponseWriter)
func User ¶
func User(w http.ResponseWriter, u models.UserResponse)
Types ¶
type Builder ¶
type Builder struct { Response ErrResponse ResponseWriter http.ResponseWriter }
func NewErrorBuilder ¶
func NewErrorBuilder() *Builder
func (*Builder) SetMessage ¶
func (*Builder) SetResponseCode ¶
type ErrResponse ¶
type ErrorResponse ¶
type ErrorResponse struct { Code int32 `json:"code"` Reason string `json:"reason"` Message string `json:"message,omitempty"` Error string `json:"error,omitempty"` Data data `json:"data"` }
func NewAccessDeniedErrorResponse ¶
func NewAccessDeniedErrorResponse() *ErrorResponse
func NewBadRequestErrorResponse ¶
func NewBadRequestErrorResponse(msg string) *ErrorResponse
func NewConflictResponse ¶
func NewConflictResponse(msg string) *ErrorResponse
func NewErrorResponse ¶
func NewErrorResponse(statusCode int32, reason, message string) *ErrorResponse
func NewInternalServerErrorErrorResponse ¶
func NewInternalServerErrorErrorResponse() *ErrorResponse
func NewServiceUnavailableErrorResponse ¶
func NewServiceUnavailableErrorResponse() *ErrorResponse
func NewUnauthorizedErrorResponse ¶
func NewUnauthorizedErrorResponse(msg string) *ErrorResponse
type NotFoundResponse ¶
swagger:model NotFoundError
func NewNotFoundResponse ¶
func NewNotFoundResponse() *NotFoundResponse
type StatusError ¶
type UnauthorizedResponse ¶
type UnauthorizedResponse struct {}
func NewUnauthorizedResponse ¶
func NewUnauthorizedResponse() *UnauthorizedResponse
type UserResponse ¶
type UserResponse struct {
*models.UserResponse `json:"user"`
}
Click to show internal directories.
Click to hide internal directories.