responses

package
v0.0.0-...-0e8bb44 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CookieAuthName = "access_token"
)
View Source
const (
	ErrInternalServer = "Ошибка на сервере"
)

Variables

View Source
var ErrCookieNotPresented = myerrors.NewErrorBadFormatRequest("Должна быть выставлена cookie, а её нет")

Functions

func HandleErr

func HandleErr(w http.ResponseWriter, logger *my_logger.MyLogger, err error)

HandleErr this function handle err. If err is myerror. Error then we built this error and client get it, otherwise it is internal error and client shouldn`t get it.

func SendResponse

func SendResponse(w http.ResponseWriter, logger *my_logger.MyLogger, response any)

Types

type ErrorResponse

type ErrorResponse struct {
	Status int               `json:"status"`
	Body   ResponseBodyError `json:"body"`
}

func NewErrResponse

func NewErrResponse(status int, err string) *ErrorResponse

type ResponseBody

type ResponseBody struct {
	Message string `json:"message"`
}

type ResponseBodyError

type ResponseBodyError struct {
	Error string `json:"error"`
}

type ResponseBodyID

type ResponseBodyID struct {
	ID uint64 `json:"id"`
}

type ResponseID

type ResponseID struct {
	Status int            `json:"status"`
	Body   ResponseBodyID `json:"body"`
}

func NewResponseIDRedirect

func NewResponseIDRedirect(ID uint64) *ResponseID

type ResponseSuccessful

type ResponseSuccessful struct {
	Status int          `json:"status"`
	Body   ResponseBody `json:"body"`
}

func NewResponseSuccessful

func NewResponseSuccessful(message string) *ResponseSuccessful

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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