httputil

package
v0.0.0-...-16dfdc2 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllowMethod

func AllowMethod(w http.ResponseWriter, m string, ms ...string) bool

allowMethod verifies that the given method is one of the allowed methods, and if not, it writes an error to w. A boolean is returned indicating whether or not the method is allowed.

func WriteError

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

writeError logs and writes the given Error to the ResponseWriter If Error is an VDL error, it is rendered to the ResponseWriter Otherwise, it is assumed to be a StatusInternalServerError

Types

type HTTPError

type HTTPError struct {
	Message string `json:"message"`
	// Code is the HTTP status code
	Code int `json:"-"`
}

func NewHTTPError

func NewHTTPError(code int, m string) *HTTPError

func (HTTPError) Error

func (e HTTPError) Error() string

func (HTTPError) WriteTo

func (e HTTPError) WriteTo(w http.ResponseWriter) error

Jump to

Keyboard shortcuts

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