mrresp

package
v0.18.3 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrorAttributeIDByDefault = "generalError" // ErrorAttributeIDByDefault - название пользовательской ошибки по умолчанию
)

Variables

This section is empty.

Functions

func HandlerErrorResponse added in v0.18.0

func HandlerErrorResponse(status, unexpectedStatus int, title, details string) http.HandlerFunc

HandlerErrorResponse - comment func.

func HandlerGetFatalErrorAsJSON added in v0.18.0

func HandlerGetFatalErrorAsJSON(unexpectedStatus int) http.HandlerFunc

HandlerGetFatalErrorAsJSON - comment func.

func HandlerGetHealth

func HandlerGetHealth() http.HandlerFunc

HandlerGetHealth - comment func.

func HandlerGetMethodNotAllowedAsJSON added in v0.18.0

func HandlerGetMethodNotAllowedAsJSON(unexpectedStatus int) http.HandlerFunc

HandlerGetMethodNotAllowedAsJSON - comment func.

func HandlerGetNotFoundAsJSON added in v0.18.0

func HandlerGetNotFoundAsJSON(unexpectedStatus int) http.HandlerFunc

HandlerGetNotFoundAsJSON - comment func.

func HandlerGetStatusOkAsJSON added in v0.18.0

func HandlerGetStatusOkAsJSON() http.HandlerFunc

HandlerGetStatusOkAsJSON - comment func.

func HandlerGetStructAsJSON added in v0.18.0

func HandlerGetStructAsJSON(data any, status int) (http.HandlerFunc, error)

HandlerGetStructAsJSON - comment func.

func HandlerGetSystemInfoAsJSON added in v0.18.0

func HandlerGetSystemInfoAsJSON(cfg SystemInfoConfig) (http.HandlerFunc, error)

HandlerGetSystemInfoAsJSON - comment func.

func TraceRequest added in v0.18.3

func TraceRequest(l mrlog.Logger, start time.Time, sr *mrserver.StatRequest, sw *mrserver.StatResponseWriter)

TraceRequest - comment func.

Types

type ErrorAttribute

type ErrorAttribute struct {
	ID        string `json:"id"`
	Value     string `json:"value"`
	DebugInfo string `json:"debugInfo,omitempty"`
}

ErrorAttribute - comment struct.

type ErrorDetailsResponse

type ErrorDetailsResponse struct {
	Title        string `json:"title"`
	Details      string `json:"details"`
	Request      string `json:"request"`
	Time         string `json:"time"`
	ErrorTraceID string `json:"errorTraceId,omitempty"`
}

ErrorDetailsResponse - application/problem+json (401, 403, 404, 418, 5XX).

type ErrorListResponse

type ErrorListResponse []ErrorAttribute

ErrorListResponse - application/json (400).

type ErrorSender

type ErrorSender struct {
	// contains filtered or unexported fields
}

ErrorSender - comment struct.

func NewErrorSender

func NewErrorSender(
	encoder mrserver.ResponseEncoder,
	errorHandler mrcore.ErrorHandler,
	statusGetter mrserver.ErrorStatusGetter,
	unexpectedStatus int,
	isDebug bool,
) *ErrorSender

NewErrorSender - создаёт объект ErrorSender.

func (*ErrorSender) SendError

func (rs *ErrorSender) SendError(w http.ResponseWriter, r *http.Request, err error)

SendError - отправляет клиенту ответ с ошибкой в одном из статусов: 4xx, 5XX и её деталями.

type FileSender

type FileSender struct {
	*Sender
}

FileSender - comment struct.

func NewFileSender

func NewFileSender(base *Sender) *FileSender

NewFileSender - создаёт объект FileSender.

func (*FileSender) SendAttachmentFile

func (rs *FileSender) SendAttachmentFile(ctx context.Context, w http.ResponseWriter, file mrtype.File) error

SendAttachmentFile - comment method.

func (*FileSender) SendFile

func (rs *FileSender) SendFile(ctx context.Context, w http.ResponseWriter, file mrtype.File) error

SendFile - comment method.

type Sender

type Sender struct {
	// contains filtered or unexported fields
}

Sender - comment struct.

func NewSender

func NewSender(encoder mrserver.ResponseEncoder) *Sender

NewSender - создаёт объект Sender.

func (*Sender) Send

func (rs *Sender) Send(w http.ResponseWriter, status int, structure any) error

Send - comment method.

func (*Sender) SendBytes

func (rs *Sender) SendBytes(w http.ResponseWriter, status int, body []byte) error

SendBytes - comment method.

func (*Sender) SendNoContent

func (rs *Sender) SendNoContent(w http.ResponseWriter) error

SendNoContent - comment method.

type SystemInfoConfig

type SystemInfoConfig struct {
	Name        string
	Version     string
	Environment string
	IsDebug     bool
	StartedAt   time.Time
}

SystemInfoConfig - comment struct.

Jump to

Keyboard shortcuts

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