common

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2020 License: Apache-2.0 Imports: 3 Imported by: 52

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WriteError

func WriteError(rw http.ResponseWriter, status int, err error)

WriteError writes an error to the response writer

func WriteResponse

func WriteResponse(rw http.ResponseWriter, status int, v interface{})

WriteResponse writes a response to the response writer

Types

type HTTPError

type HTTPError struct {
	// contains filtered or unexported fields
}

HTTPError holds an error and an HTTP status code

func NewHTTPError

func NewHTTPError(status int, err error) *HTTPError

NewHTTPError returns a new HTTPError

func (*HTTPError) Error

func (e *HTTPError) Error() string

Error returns the error string

func (*HTTPError) Status

func (e *HTTPError) Status() int

Status returns the status code

type HTTPHandler

type HTTPHandler interface {
	Path() string
	Method() string
	Handler() HTTPRequestHandler
}

HTTPHandler is a HTTP handler descriptor containing the context path, method, and request handler

type HTTPRequestHandler

type HTTPRequestHandler func(http.ResponseWriter, *http.Request)

HTTPRequestHandler is an HTTP handler

Jump to

Keyboard shortcuts

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