web

package
v0.0.0-...-f43e39b Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package web provides the api endpoints for the urstore

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrInternalError

func ErrInternalError(err error, message string) render.Renderer

ErrInternalError render an invalid request

func ErrInvalidRequest

func ErrInvalidRequest(err error, message string) render.Renderer

ErrInvalidRequest render an invalid request

func ErrNotFound

func ErrNotFound(err error, message string) render.Renderer

ErrNotFound render an invalid request

func RegisterEndpoints

func RegisterEndpoints() (router *chi.Mux)

RegisterEndpoints register application endpoints

Types

type ErrResponse

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

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

ErrResponse renderer type for handling all sorts of errors.

In the best case scenario, the excellent github.com/pkg/errors package helps reveal information on the error, setting it on Err, and in the Render() method, using it to set the application-specific error code in AppCode.

func (*ErrResponse) Render

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

Render an ErrResponse

Jump to

Keyboard shortcuts

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