response

package
v0.0.0-...-d0162ed Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Error

type Error struct {
	Status  int    `json:"status"`
	Error   string `json:"error"`
	Details string `json:"details,omitempty"`
	Path    string `json:"path,omitempty"`
}

Error used to respond to errored http requests.

func DefaultBadRequestError

func DefaultBadRequestError() (int, Error)

DefaultBadRequestError function returns a default 400 Bad Request HTTP status code and a custom error. It signifies that the provided request body is not valid.

func DefaultInternalError

func DefaultInternalError(c echo.Context, logger log.Logger, errorMessage string) (int, Error)

DefaultInternalError is a function that logs and returns an internal server error. It accepts an echo.Context, a log.Logger, and an error message in string format. The function generates a unique error code using uuid.NewV4(). The error message and error code are logged using the logger instance. The function then returns an HTTP status code for internal server error (500) and an Error instance with the status set to the HTTP status code, the error message set to "Internal error", and the details containing a message indicating a problem with the request and the generated error code.

func DefaultNotFoundError

func DefaultNotFoundError() (int, Error)

DefaultNotFoundError function returns a default 404 Not Found HTTP status code and a custom error. It signifies that the requested resource does not exist, or the user does not have permission to access it.

Jump to

Keyboard shortcuts

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