serviceresponse

package
v0.0.0-...-14027d0 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultPayLoadName = "payload"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DetailError

type DetailError struct {
	Code    int    `json:"code,omitempty"`
	Message string `json:"message,omitempty"`
	Detail  string `json:"detail,omitempty"`
}

type Error

type Error struct {
	Action  string        `json:"action,omitempty"`
	Message string        `json:"message,omitempty"`
	Errors  []DetailError `json:"errs,omitempty"`
	// contains filtered or unexported fields
}

func NewError

func NewError(w http.ResponseWriter, r *http.Request) *Error

///////////////////////////////////////////////////////////////////////////////////////////////// Error response /////////////////////////////////////////////////////////////////////////////////////////////////

func (*Error) AddDetail

func (e *Error) AddDetail(err error)

func (*Error) AddValidatorDetail

func (e *Error) AddValidatorDetail(err error, message string)

func (*Error) Write

func (e *Error) Write(code int, headers map[string]string) (err error)

type Meta

type Meta struct {
	Size     int `json:"size"`
	NextPage int `json:"nextPage"`
	Count    int `json:"count"`
	Page     int `json:"page"`
}

type ServiceError

type ServiceError struct {
	Code    int
	Message string
	Detail  string
}

func New

func New() *ServiceError

func (*ServiceError) DecodeHttpCode

func (se *ServiceError) DecodeHttpCode(statusCode int, message string)

func (*ServiceError) Error

func (se *ServiceError) Error() string

type Success

type Success struct {
	Action      string      `json:"action,omitempty"`
	PayloadName string      `json:"-"`
	Data        interface{} `json:"data"`
	Meta        interface{} `json:"meta"`
	// contains filtered or unexported fields
}

func NewSuccess

func NewSuccess(w http.ResponseWriter, r *http.Request) *Success

///////////////////////////////////////////////////////////////////////////////////////////////// Success Response /////////////////////////////////////////////////////////////////////////////////////////////////

func (*Success) DataName

func (s *Success) DataName() string

func (*Success) Write

func (s *Success) Write(code int, headers map[string]string) (err error)

func (*Success) WriteOk

func (s *Success) WriteOk() (err error)

Jump to

Keyboard shortcuts

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