Documentation ¶
Index ¶
- Constants
- func HandlerErrorResponse(status, unexpectedStatus int, title, details string) http.HandlerFunc
- func HandlerGetFatalErrorAsJSON(unexpectedStatus int) http.HandlerFunc
- func HandlerGetHealth() http.HandlerFunc
- func HandlerGetMethodNotAllowedAsJSON(unexpectedStatus int) http.HandlerFunc
- func HandlerGetNotFoundAsJSON(unexpectedStatus int) http.HandlerFunc
- func HandlerGetStatusOkAsJSON() http.HandlerFunc
- func HandlerGetStructAsJSON(data any, status int) (http.HandlerFunc, error)
- func HandlerGetSystemInfoAsJSON(cfg SystemInfoConfig) (http.HandlerFunc, error)
- func TraceRequest(l mrlog.Logger, start time.Time, sr *mrserver.StatRequest, ...)
- type ErrorAttribute
- type ErrorDetailsResponse
- type ErrorListResponse
- type ErrorSender
- type FileSender
- type Sender
- type SystemInfoConfig
Constants ¶
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 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) SendNoContent ¶
func (rs *Sender) SendNoContent(w http.ResponseWriter) error
SendNoContent - comment method.