common

package
v0.0.0-...-589bc69 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2018 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package common is used to hold things that multiple packags within the mediocre-api toolkit will need to use or reference

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HTTPError

func HTTPError(w http.ResponseWriter, r *http.Request, err error)

HTTPError will attempt to cast the given error to an ExpectedErr. If it's able to it will write that error and its response code back to the http.ResponseWriter. Otherwise it will log the error and send back a 500 unknown server-side error. If err is nil it will do nothing.

Types

type ExpectedErr

type ExpectedErr struct {
	Code int
	Err  string
}

ExpectedErr is an implementation of the error interface which will be used to indicate that the error being returned is an expected one and can sent back to the client

func ExpectedErrf

func ExpectedErrf(code int, s string, args ...interface{}) ExpectedErr

ExpectedErrf returns an ExpectedErr with a formatted message

func (ExpectedErr) Error

func (e ExpectedErr) Error() string

Error implements the error interface

Directories

Path Synopsis
Package apihelper contains some methods which make working with the http package a bit nicer
Package apihelper contains some methods which make working with the http package a bit nicer
Package commontest holds methods which are helpful when writing tests within mediocre-api
Package commontest holds methods which are helpful when writing tests within mediocre-api
Package resphelper provides a number of methods for working with radix.v2 Resp structs
Package resphelper provides a number of methods for working with radix.v2 Resp structs

Jump to

Keyboard shortcuts

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