response

package
v2.11.3 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// 400
	BadRequest              = "Bad Request"
	RequestValidationFailed = "request validation failed"
	EmailIsWrong            = "email is wrong"
	PasswordIsWrong         = "password is wrong"
	PermissionIsRepeat      = "permission is repeat"

	// 401
	Unauthorized = "Unauthorized"

	// 403
	Forbidden = "Forbidden"

	// 500
	InternalServerError = "Internal Server Error"

	// 503
	ServiceUnavailable = "Service Unavailable"
)

Variables

View Source
var MessageToCode = map[string]string{
	BadRequest:              "400-001",
	RequestValidationFailed: "400-002",
	EmailIsWrong:            "400-003",
	PasswordIsWrong:         "400-004",
	PermissionIsRepeat:      "400-005",
	Unauthorized:            "401-001",
	Forbidden:               "403-001",
	InternalServerError:     "500-001",
	ServiceUnavailable:      "503-001",
}

Functions

This section is empty.

Types

type Debug

type Debug struct {
	Error string `json:"error" example:"error message" validate:"required"`

	Stacktrace []string `json:"stacktrace" validate:"required"`
	// contains filtered or unexported fields
}

type ErrorResponse

type ErrorResponse struct {
	Message string `json:"message" validate:"required"`
	Code    string `json:"code" validate:"required"`

	Debug   *Debug         `json:"debug,omitempty"`
	Context map[string]any `json:"context,omitempty"`
	// contains filtered or unexported fields
}

func NewErrorResponse

func NewErrorResponse(message string, err error, context map[string]any) *ErrorResponse

func (*ErrorResponse) MakeLogFields

func (er *ErrorResponse) MakeLogFields(req *http.Request, fields ...zap.Field) []zap.Field

func (*ErrorResponse) StatusCode

func (er *ErrorResponse) StatusCode() int

type Response

type Response struct {
	Data any `json:"data" validate:"required"`
}

func NewResponse

func NewResponse(data any) *Response

Jump to

Keyboard shortcuts

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