response

package
v0.0.0-...-12e9e95 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2024 License: MIT Imports: 7 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BasicResponse

type BasicResponse struct {
	Code    int         `json:"code" example:"500"`                      // HTTP status code.
	Message string      `json:"message" example:"internal_server_error"` // Message corresponding to the status code.
	Error   string      `json:"error" example:"{$err}"`                  // error message.
	Data    interface{} `json:"data,omitempty"`
}

BasicResponse represents a failed response structure for API responses.

func BasicBuilder

func BasicBuilder(result BasicResponse) BasicResponse

BasicBuilder constructs a BasicBuilder based on the provided error.

func (BasicResponse) Send

func (c BasicResponse) Send(ctx echo.Context) error

Send sends the CustomResponse as a JSON response using the provided Echo context.

type FailedResponse

type FailedResponse struct {
	Code    int                       `json:"code" example:"500"`                      // HTTP status code.
	Message constants.ResponseMessage `json:"message" example:"internal_server_error"` // Message corresponding to the status code.
	Error   string                    `json:"error" example:"{$err}"`                  // error message.
}

FailedResponse represents a failed response structure for API responses.

func ErrorBuilder

func ErrorBuilder(err error) FailedResponse

ErrorBuilder constructs a FailedResponse based on the provided error.

func (FailedResponse) Send

func (x FailedResponse) Send(c echo.Context) error

Send sends the CustomResponse as a JSON response using the provided Echo context.

type Meta

type Meta struct {
	Meta interface{} `json:"meta,omitempty"` //pagination payload.
	Success
}

type ResponseFormat

type ResponseFormat struct {
	Code    int                       `json:"code" example:"200"` // HTTP status code.
	Message constants.ResponseMessage `json:"message" example:"success"`
}

type Success

type Success struct {
	ResponseFormat
	Data interface{} `json:"data,omitempty"` // data payload.
}

type SuccessResponse

type SuccessResponse struct {
	Success
	Meta
}

SuccessResponse represents a success response structure for API responses.

func SuccessBuilder

func SuccessBuilder(response interface{}, meta ...interface{}) SuccessResponse

SuccessBuilder constructs a CustomResponse with a Success status and the provided response data.

func SuccessNoResponseBuilder

func SuccessNoResponseBuilder() SuccessResponse

func (SuccessResponse) Send

func (c SuccessResponse) Send(ctx echo.Context) error

Send sends the CustomResponse as a JSON response using the provided Echo context.

Jump to

Keyboard shortcuts

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