shared

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2022 License: MIT Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	API_ERROR_FORMAT = "api-error: %s"
)
View Source
var (
	DEBUG = false
)

Functions

func GetLogger

func GetLogger(ctx context.Context) logger

func GetRequest

func GetRequest(ctx context.Context) *http.Request

func Redirect

func Redirect(code int, location string) interface {
	error
	Redirector
}

func SetLogger

func SetLogger(ctx context.Context, l logger) context.Context

func SetRequest

func SetRequest(ctx context.Context, req *http.Request) context.Context

func StatusCodeOf

func StatusCodeOf(err error) int

func StatusCodeOfOrDefault

func StatusCodeOfOrDefault(err error, code int) int

Types

type APIError

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

func NewAPIError

func NewAPIError(err error, code int) *APIError

func (*APIError) Error

func (e *APIError) Error() string

func (*APIError) StatusCode

func (e *APIError) StatusCode() int

func (*APIError) Unwrap

func (e *APIError) Unwrap() error

type Empty

type Empty struct{}

Empty is zero Input

type ErrorResponse

type ErrorResponse struct {
	Code   int      `json:"code"`
	Error  string   `json:"error"`
	Detail []string `json:"detail,omitempty"`
}

ErrorResponse represents a normal error response type

type Redirector

type Redirector interface {
	Redirect(http.ResponseWriter, *http.Request)
}

type StatusCoder

type StatusCoder interface {
	StatusCode() int
}

func NoContent

func NoContent(code int) StatusCoder

Jump to

Keyboard shortcuts

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