core_dtos

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: May 19, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OkStatus   = "ok"
	FailStatus = "fail"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrorItem

type ErrorItem struct {
	Key     int    `json:"key"`
	Message string `json:"message"`
}

ErrorItem contains error's key and message

type Option added in v1.2.1

type Option func(o *ResponseOptions)

func WithContext added in v1.2.1

func WithContext(ctx fiber.Ctx) Option

func WithOldContext added in v1.2.1

func WithOldContext(ctx *fiberold.Ctx) Option

type ResponseDto

type ResponseDto struct {
	ResponseOptions

	Status  string        `json:"status"`
	Message string        `json:"message"`
	Errors  []ErrorItem   `json:"errors"`
	Data    []interface{} `json:"data"`

	TmRequest   string    `json:"tm_req"`
	TmRequestSt time.Time `json:"-"`
	// contains filtered or unexported fields
}

ResponseDto generic response DTO

func NewResp added in v1.2.1

func NewResp(opts ...Option) *ResponseDto

NewResp wrap context (compatible both for v2 and v3)

func NewResponse

func NewResponse(ctx fiber.Ctx) *ResponseDto

NewResponse wrap context (compatible only with fiber v3)

func (*ResponseDto) File added in v1.4.0

func (r *ResponseDto) File() error

File finalize response and convert to file

func (*ResponseDto) JSON

func (r *ResponseDto) JSON() error

JSON finalize response and convert to Json

func (*ResponseDto) SetData

func (r *ResponseDto) SetData(data interface{})

SetData response data

func (*ResponseDto) SetError

func (r *ResponseDto) SetError(key int, msg string) *ResponseDto

SetError set key/msg error

func (*ResponseDto) SetFile added in v1.4.0

func (r *ResponseDto) SetFile(name string, data []byte)

SetFile name and data

func (*ResponseDto) SetHeaders

func (r *ResponseDto) SetHeaders(headers map[string]string)

SetHeaders response headers

func (*ResponseDto) SetMessage

func (r *ResponseDto) SetMessage(text string)

SetMessage response message

func (*ResponseDto) SetStatus

func (r *ResponseDto) SetStatus(status int)

SetStatus response status

type ResponseOptions added in v1.2.1

type ResponseOptions struct {
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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