response

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: May 23, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BadRequest

func BadRequest(c echo.Context, message string) error

BadRequest sends a 400 response with error message

func Created

func Created(c echo.Context, data any) error

Created sends a 201 response with data

func Forbidden

func Forbidden(c echo.Context, message string) error

Forbidden sends a 403 response with error message

func InternalError

func InternalError(c echo.Context, message string) error

InternalError sends a 500 response with error message

func JSON

func JSON(c echo.Context, status int, data any) error

JSON sends a JSON response with the given status code and data

func JSONCreated

func JSONCreated(c echo.Context, message string) error

JSONCreated sends a JSON created response

func JSONError

func JSONError(c echo.Context, status int, message string) error

JSONError sends a JSON error response

func JSONForbidden

func JSONForbidden(c echo.Context, message string) error

JSONForbidden sends a JSON forbidden response

func JSONNotFound

func JSONNotFound(c echo.Context, message string) error

JSONNotFound sends a JSON not found response

func JSONSuccess

func JSONSuccess(c echo.Context, message string) error

JSONSuccess sends a JSON success response

func JSONUnauthorized

func JSONUnauthorized(c echo.Context, message string) error

JSONUnauthorized sends a JSON unauthorized response

func NotFound

func NotFound(c echo.Context, message string) error

NotFound sends a 404 response with error message

func Success

func Success(c echo.Context, data any) error

Success sends a successful response with data

func Unauthorized

func Unauthorized(c echo.Context, message string) error

Unauthorized sends a 401 response with error message

Types

type MapResponse

type MapResponse struct {
	Data map[string]any `json:"data"`
}

MapResponse represents a map response

func NewMapResponse

func NewMapResponse(data map[string]any) *MapResponse

NewMapResponse creates a new map response

type Response

type Response struct {
	Status  string `json:"status"`
	Message string `json:"message,omitempty"`
	Data    any    `json:"data,omitempty"`
	// contains filtered or unexported fields
}

Response represents the standard API response format

func (*Response) Equal

func (r *Response) Equal(other *Response) bool

Equal compares two responses for equality

func (*Response) SetLogger

func (r *Response) SetLogger(logger logging.Logger) error

SetLogger sets the logger for the response

Jump to

Keyboard shortcuts

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