http_err

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2024 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrStatusOK         = &ErrorResponse{StatusCode: http.StatusOK, Message: "Status OK"}
	ErrBadRequest       = &ErrorResponse{StatusCode: http.StatusBadRequest, Message: "Bad request"}
	ErrUnauthorized     = &ErrorResponse{StatusCode: http.StatusUnauthorized, Message: "Unauthorized"}
	ErrForbidden        = &ErrorResponse{StatusCode: http.StatusForbidden, Message: "Access forbidden"}
	ErrNotFound         = &ErrorResponse{StatusCode: http.StatusNotFound, Message: "Resource not found"}
	ErrMethodNotAllowed = &ErrorResponse{StatusCode: http.StatusMethodNotAllowed, Message: "Method not allowed"}
	ErrInternalServer   = &ErrorResponse{StatusCode: http.StatusInternalServerError, Message: "Internal Server Error"}
	ErrStrAuthIncorrect = "Auth data incorrect"
)

Functions

func NewErrorResponse

func NewErrorResponse(c *gin.Context, statusCode int, message string)

Types

type ErrorResponse

type ErrorResponse struct {
	Err        error  `json:"-"`
	StatusCode int    `json:"-"`
	StatusText string `json:"status_text"`
	Message    string `json:"message"`
}

func ErrorRenderer

func ErrorRenderer(err error) *ErrorResponse

func ServerErrorRenderer

func ServerErrorRenderer(err error) *ErrorResponse

type StatusResponse

type StatusResponse struct {
	Status string `json:"status"`
}

Jump to

Keyboard shortcuts

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