response

package
v0.0.0-...-1c7db09 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInternalServerError = "internal server error"
	ErrNotFound            = "not found"
	ErrBadRequest          = "bad request"
	ErrForbidden           = "forbidden"
	ErrUnauthorized        = "unauthorized"
	ErrTooManyRequest      = "too many request"
	ErrConflict            = "conflict"
	ErrUnprocessEntity     = "unprocessable entity"
)

Functions

func ParseHttpResponse

func ParseHttpResponse(resp interface{}) (int, interface{})

Types

type ErrorResponse

type ErrorResponse struct {
	Meta    MetaResponse `json:"meta"`
	Errors  []string     `json:"errors"`
	Payload interface{}  `json:"payload,omitempty"`
}

func (ErrorResponse) Error

func (e ErrorResponse) Error() string

func (ErrorResponse) ResponseCode

func (e ErrorResponse) ResponseCode() int

func (ErrorResponse) ResponseErrors

func (e ErrorResponse) ResponseErrors() []string

func (ErrorResponse) ResponseMessage

func (e ErrorResponse) ResponseMessage() string

func (ErrorResponse) ResponseMeta

func (e ErrorResponse) ResponseMeta() MetaResponse

func (ErrorResponse) ResponsePayload

func (e ErrorResponse) ResponsePayload() any

type MetaResponse

type MetaResponse struct {
	Success    bool   `json:"success"`
	Message    string `json:"message"`
	StatusCode int    `json:"status_code"`
}

type ResponseSuccess

type ResponseSuccess interface {
	ResponseCode() int
	ResponseData() interface{}
	ResponseErrors() bool
	ResponseMessage() string
	ResponsePayload() interface{}
	ResponseMeta() MetaResponse
}

func NewHttpCreated

func NewHttpCreated(data interface{}) ResponseSuccess

func NewHttpOK

func NewHttpOK(data interface{}) ResponseSuccess

type RestError

type RestError interface {
	error
	ResponseMeta() MetaResponse
	ResponseCode() int
	ResponseErrors() []string
	ResponseMessage() string
	ResponsePayload() any
}

func NewHttpBadRequest

func NewHttpBadRequest(errors []string, payload any) RestError

func NewHttpConflict

func NewHttpConflict(errors []string) RestError

func NewHttpError

func NewHttpError(code int, message string, errors []string, payload any) RestError

func NewHttpForbidden

func NewHttpForbidden(errors []string) RestError

func NewHttpInternalServerError

func NewHttpInternalServerError(message string) RestError

func NewHttpNotFound

func NewHttpNotFound(errors []string, payload any) RestError

func NewHttpTooManyRequest

func NewHttpTooManyRequest(errors []string) RestError

func NewHttpUnauthorized

func NewHttpUnauthorized(errors []string, payload any) RestError

func NewHttpUnprocessedEntity

func NewHttpUnprocessedEntity(errors []string) RestError

func NewHttpValidationError

func NewHttpValidationError(payload any) RestError

func NewParseSQLError

func NewParseSQLError(err error) RestError

func NewParseSQLUniqueError

func NewParseSQLUniqueError(err error) RestError

func ParseHttpError

func ParseHttpError(err error) RestError

Parse error for security response...

type SuccessResponse

type SuccessResponse struct {
	Meta    MetaResponse `json:"meta"`
	Error   bool         `json:"error"`
	Payload interface{}  `json:"payload,omitempty"`
	Data    interface{}  `json:"data,omitempty"`
}

func (SuccessResponse) ResponseCode

func (e SuccessResponse) ResponseCode() int

func (SuccessResponse) ResponseData

func (e SuccessResponse) ResponseData() interface{}

func (SuccessResponse) ResponseErrors

func (e SuccessResponse) ResponseErrors() bool

func (SuccessResponse) ResponseMessage

func (e SuccessResponse) ResponseMessage() string

func (SuccessResponse) ResponseMeta

func (e SuccessResponse) ResponseMeta() MetaResponse

func (SuccessResponse) ResponsePayload

func (e SuccessResponse) ResponsePayload() interface{}

func (SuccessResponse) String

func (e SuccessResponse) String() string

Jump to

Keyboard shortcuts

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