response

package
v0.0.0-...-857c71f Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ReponseOption

type ReponseOption func(resp *Response)

func Data

func Data(data any) ReponseOption

return as data

{
	code:0,
	message:"OK"
	data:any
}

func Error

func Error(err *apperror.Error) ReponseOption

func Message

func Message(msg string) ReponseOption

func Meta

func Meta(meta any, keyValues ...map[string]any) ReponseOption

return as data in format

Case: Map | Struct

{
	code:0,
	message:"OK"
	meta:{
		key:value
	}
}

Case: Slices

{
	code:0,
	message:"OK"
	meta:{
		list:[]
		[key]:value
	}
}

func Status

func Status(status int) ReponseOption

Ovewrite default status

Status(http.StatusCreated)

type Response

type Response struct {
	Code    int    `json:"code"`
	Message string `json:"message"`

	// The Data field contains the actual response data
	Data any `json:"data,omitempty"`

	// Meta provides additional information about the data, such as its type or kind.y.
	Meta any `json:"meta,omitempty"`
	// contains filtered or unexported fields
}

func New

func New(opts ...ReponseOption) *Response

func (*Response) Parse

func (r *Response) Parse(c echo.Context) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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