utils

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNS             = errorx.NewNamespace("error.api")
	ErrAuth           = ErrNS.NewType("auth")
	ErrOther          = ErrNS.NewType("other")
	ErrInvalidRequest = ErrNS.NewType("invalid_request")
	ErrInternalServer = ErrNS.NewType("internal_server_error")
	ErrNotFound       = ErrNS.NewType("resource_not_found")
)

Functions

func ExecWithDeadline added in v1.0.2

func ExecWithDeadline(t <-chan time.Time, cmd *exec.Cmd) error

func MWHandleErrors

func MWHandleErrors() gin.HandlerFunc

MWHandleErrors creates a middleware that turns (last) error in the context into an APIError json response. In handlers, `c.Error(err)` can be used to attach the error to the context. When error is attached in the context: - The handler can optionally assign the HTTP status code. - The handler must not self-generate a response body.

Types

type APIError

type APIError struct {
	Error    bool   `json:"error"`
	Message  string `json:"message"`
	Code     string `json:"code"`
	FullText string `json:"full_text"`
}

type Response

type Response struct {
	Status  int    `json:"status"`
	Message string `json:"message"`
	UID     string `json:"uid"`
}

func AttackSuccessResponse

func AttackSuccessResponse(uid string) *Response

func RecoverSuccessResponse

func RecoverSuccessResponse(uid string) *Response

Jump to

Keyboard shortcuts

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