Version: v0.0.0-...-6719cd2 Latest Latest

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

Go to latest
Published: Jul 18, 2019 License: Apache-2.0 Imports: 4 Imported by: 0



Package web aids in writing HTTP servers.



This section is empty.


This section is empty.


func NewError

func NewError(statusCode int, formatMsg string, formatParams ...interface{}) error

NewError constructs a NewApiError with the supplied HTTP Status Code and formats the supplied msg & arguments

func Write

func Write(w http.ResponseWriter, vals ...interface{})

Write is a helper function to write out a http response. It'll write the first non-nil val in the val list (so you can do things like web.Write(w, err, foo)) and have err returned if it was set.

func WriteError

func WriteError(w http.ResponseWriter, statusCode int, formatMsg string, params ...interface{})

WriteError will write a textual error response to the supplied ResponseWriter with the supplied HTTP StatusCode


type APIError

type APIError struct {
	// contains filtered or unexported fields

APIError defines an error that is destined to be a HTTP response. It includes both a textual message and HTTP Status Code to use. Construct an APIError using NewError.

func (*APIError) Error

func (a *APIError) Error() string

Error implements the standard error interface

func (*APIError) HTTPWrite

func (a *APIError) HTTPWrite(w http.ResponseWriter)

HTTPWrite can be called to return this error as a HTTP Response

type HTTPWriter

type HTTPWriter interface {
	HTTPWrite(w http.ResponseWriter)

HTTPWriter defines a way for a type to control how its returned as a HTTP response values passed to Write that implement this interface will have their HTTPWrite function called to generate the HTTP Response

Source Files

Jump to

Keyboard shortcuts

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