core

package
v0.0.0-...-c950848 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2021 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = &ErrResponse{HTTPStatusCode: 404, StatusText: "Not Found"}

ErrNotFound – The requested resource doesn't exist.

View Source
var ErrTooManyRequests = &ErrResponse{HTTPStatusCode: 429, StatusText: "Too Many Requests"}

ErrTooManyRequests – Too many requests hit the API too quickly. We recommend an exponential backoff of your requests.

View Source
var ErrUnauthorized = &ErrResponse{HTTPStatusCode: 401, StatusText: "Unauthorized"}

ErrUnauthorized – No valid API token provided.

Functions

func ErrConflict

func ErrConflict(err error) render.Renderer

ErrConflict – The request conflicts with another request (perhaps due to using the same idempotent key).

func ErrInvalidRequest

func ErrInvalidRequest(err error) render.Renderer

ErrInvalidRequest – The request was unacceptable, often due to missing a required parameter.

func ErrRender

func ErrRender(err error) render.Renderer

ErrRender response error writer

func ErrRequestFailed

func ErrRequestFailed(err error) render.Renderer

ErrRequestFailed – The parameters were valid but the request failed.

Types

type ErrResponse

type ErrResponse struct {
	Err            error `json:"-"` // low-level runtime error
	HTTPStatusCode int   `json:"-"` // http response status code

	StatusText string `json:"status"`          // user-level status message
	AppCode    int64  `json:"code,omitempty"`  // application-specific error code
	ErrorText  string `json:"error,omitempty"` // application-level error message, for debugging
}

ErrResponse contains error information

func (*ErrResponse) Render

func (e *ErrResponse) Render(w http.ResponseWriter, r *http.Request) error

Render response writer

type Handler

type Handler struct {
	DB     *pg.DB
	Routes *chi.Mux
	Tx     *pg.Tx
}

Handler consists of the DB connection and Routes

Jump to

Keyboard shortcuts

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