api

package
v0.0.0-...-ce453ac Latest Latest
Warning

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

Go to latest
Published: May 25, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WriteError

func WriteError(ctx context.Context, w http.ResponseWriter, error AppError, l *zap.Logger)

func WriteSuccess

func WriteSuccess(ctx context.Context, w http.ResponseWriter, success interface{}, status int, l *zap.Logger)

Types

type AppError

type AppError struct {
	// Наименование ошибки
	Name string `json:"name" validate:"required" example:"NotFound"`
	// Сообщение ошибки
	Message string `json:"message" validate:"required" example:"entity not found"`
	// Код ошибки
	Code int `json:"code" validate:"required" example:"26002"`
	// Статус код ответа
	Status int `json:"status" validate:"required" example:"404"`

} //	@AppError

func (AppError) SetMessage

func (e AppError) SetMessage(msg string) *AppError

type Error

type Error struct {
	Status    string   `json:"status"`
	Error     AppError `json:"error"`
	RequestID string   `json:"request_id"`
}

type Success

type Success struct {
	Status    string      `json:"status"`
	Content   interface{} `json:"content"`
	RequestID string      `json:"request_id"`
}

Jump to

Keyboard shortcuts

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