api

package
v0.0.0-...-9e98dbc Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound       = ErrorType{"NOT_FOUND", http.StatusNotFound}
	ErrInternalServer = ErrorType{"INTERNAL_SERVER_ERROR", http.StatusInternalServerError}
	ErrForbidden      = ErrorType{"FORBIDDEN", http.StatusForbidden}
	ErrConflict       = ErrorType{"CONFLICT", http.StatusConflict}
	ErrBadRequest     = ErrorType{"BAD_REQUEST", http.StatusBadRequest}
	ErrValidation     = ErrorType{"VALIDATION_ERROR", http.StatusUnprocessableEntity}
	ErrUnauthorized   = ErrorType{"UNAUTHORIZED", http.StatusUnauthorized}
	ErrNotImplemented = ErrorType{"NOT_IMPLEMENTED", http.StatusNotImplemented}
)

Functions

This section is empty.

Types

type BadRequestError

type BadRequestError struct {
	Error  string            `json:"error" example:"BAD_REQUEST"`
	Detail map[string]string `json:"detail" example:"message:Error message"`
}

types used for better swagger docs

type ConflictError

type ConflictError struct {
	Error  string            `json:"error" example:"CONFLICT"`
	Detail map[string]string `json:"detail" example:"message:Error message"`
}

type Error

type Error[T any] struct {
	Error  string `json:"error" example:"NOT_FOUND"`
	Detail T      `json:"detail"`
}

func DetailedError

func DetailedError[T any](
	error ErrorType,
	detail T,
) (status int, body Error[T])

func Err

func Err(
	error ErrorType,
	message string,
) (status int, body Error[map[string]string])

type ErrorType

type ErrorType struct {
	Name       string `json:"name"`
	StatusCode int    `json:"status_code"`
}

type ForbiddenError

type ForbiddenError struct {
	Error  string            `json:"error" example:"FORBIDDEN"`
	Detail map[string]string `json:"detail" example:"message:Error message"`
}

type InternalServerError

type InternalServerError struct {
	Error  string            `json:"error" example:"INTERNAL_SERVER_ERROR"`
	Detail map[string]string `json:"detail" example:"message:Error message"`
}

type NotFoundError

type NotFoundError struct {
	Error  string            `json:"error" example:"NOT_FOUND"`
	Detail map[string]string `json:"detail" example:"message:Error message"`
}

type NotImplementedError

type NotImplementedError struct {
	Error  string            `json:"error" example:"NOT_IMPLEMENTED"`
	Detail map[string]string `json:"detail" example:"message:Error message"`
}

type UnauthorizedError

type UnauthorizedError struct {
	Error  string            `json:"error" example:"UNAUTHORIZED"`
	Detail map[string]string `json:"detail" example:"message:Error message"`
}

type ValidationError

type ValidationError struct {
	Error  string                  `json:"error" example:"VALIDATION_ERROR"`
	Detail []ValidationErrorDetail `json:"detail"`
}

type ValidationErrorDetail

type ValidationErrorDetail struct {
	Field string `json:"field" example:"username"`
	Error string `json:"error" example:"required"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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