response

package
v0.0.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 19, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const ErrMaxStack = 5

Variables

This section is empty.

Functions

func DataYay

func DataYay(w http.ResponseWriter, r *http.Request, filename string, content []byte)

func Nay

func Nay(w http.ResponseWriter, r *http.Request, err error, details ...interface{})

func Yay

func Yay(w http.ResponseWriter, r *http.Request, status int, content interface{})

Types

type Causer

type Causer interface {
	Cause() error
}

type Error

type Error struct {
	Code    utils.BusinessCode `json:"code"`
	Message string             `json:"message"`
	Reasons map[string]string  `json:"reasons"`
	Details []interface{}      `json:"details,omitempty"`
}

func (*Error) Error

func (err *Error) Error() string

type ErrorBadRequest

type ErrorBadRequest struct {
	Code    string           `json:"code" example:"400"`
	Message string           `json:"message" example:"Data is not valid"`
	Reasons map[string]error `json:"reasons"`
}

type ErrorForbiddenError

type ErrorForbiddenError struct {
	Code    string           `json:"code" example:"403"`
	Message string           `json:"message" example:"You don't have permission to access this"`
	Reasons map[string]error `json:"reasons"`
}

type ErrorInternalServerError

type ErrorInternalServerError struct {
	Code    string           `json:"code" example:"500"`
	Message string           `json:"message" example:"Something went wrong, please try again"`
	Reasons map[string]error `json:"reasons"`
}

type Response

type Response struct {
	RequestId string      `json:"request_id"`
	Content   interface{} `json:"content"`
	Error     *Error      `json:"error,omitempty"`
	Status    int         `json:"status"`
	Message   string      `json:"message"`
}

func (*Response) Render

func (res *Response) Render(w http.ResponseWriter, r *http.Request) error

type ResponseBadRequest

type ResponseBadRequest struct {
	RequestId string           `json:"request_id" example:"onelabs/IkhB54kdJd-000006"`
	Error     *ErrorBadRequest `json:"error,omitempty"`
	Status    int              `json:"status" example:"400"`
}

type ResponseForbiddenError

type ResponseForbiddenError struct {
	RequestId string               `json:"request_id" example:"onelabs/IkhB54kdJd-000006"`
	Error     *ErrorForbiddenError `json:"error,omitempty"`
	Status    int                  `json:"status" example:"403"`
}

type ResponseInternalServerError

type ResponseInternalServerError struct {
	RequestId string                    `json:"request_id" example:"onelabs/IkhB54kdJd-000006"`
	Error     *ErrorInternalServerError `json:"error,omitempty"`
	Status    int                       `json:"status" example:"500"`
}

type ResponseSuccess

type ResponseSuccess struct {
	RequestId string      `json:"request_id" example:"onelabs/IkhB54kdJd-000006"`
	Content   interface{} `json:"content"`
	Status    int         `json:"status" example:"200"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL