rest

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeRequestIntoStruct

func DecodeRequestIntoStruct(w http.ResponseWriter, r *http.Request, dest interface{}) error

func ReturnError

func ReturnError(w http.ResponseWriter, err error, httpStatus int)

func ReturnInternalServerError

func ReturnInternalServerError(w http.ResponseWriter, code, message string)

func ReturnRawError

func ReturnRawError(w http.ResponseWriter, code, message string, status int)

Returns a Raw error writting the code and the message received

func ReturnResponseToClient

func ReturnResponseToClient(w http.ResponseWriter, value interface{})

func ReturnResponseToClientWithStatus

func ReturnResponseToClientWithStatus(w http.ResponseWriter, value interface{}, httpStatus int)

func SendResponse added in v0.1.3

func SendResponse(w http.ResponseWriter, statusCode int, success bool, message string, data interface{}, errors interface{}, pagination *Pagination)

SendResponse envía una respuesta JSON con la estructura común

Types

type APIResponse added in v0.1.3

type APIResponse struct {
	Success bool        `json:"success"`
	Message string      `json:"message,omitempty"`
	Data    interface{} `json:"data,omitempty"`
	Errors  interface{} `json:"errors,omitempty"`
	Meta    Meta        `json:"meta"`
}

APIResponse es la estructura común para todas las respuestas

type ErrorDTO

type ErrorDTO struct {
	Code      string    `json:"code"`
	Message   string    `json:"message"`
	Timestamp time.Time `json:"timestamp"`
}

func NewErrorDTO

func NewErrorDTO(code, message string) ErrorDTO

NewErrorDTO returns a new ErrorDTO

type Meta added in v0.1.3

type Meta struct {
	Timestamp  string      `json:"timestamp"`
	RequestID  string      `json:"requestId,omitempty"`
	Pagination *Pagination `json:"pagination,omitempty"`
}

Meta contains additional metadatadata

type Pagination added in v0.1.3

type Pagination struct {
	Page       int `json:"page"`
	PageSize   int `json:"pageSize"`
	TotalPages int `json:"totalPages"`
	TotalItems int `json:"totalItems"`
}

Pagination contains pagination information

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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