http

package
v0.0.0-...-4d13c9b Latest Latest
Warning

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

Go to latest
Published: May 16, 2019 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client represents a http client that has a one to one relationship with a url

func NewClient

func NewClient(client *http.Client, url string) *Client

NewClient creates a Client with the http.Client and url

func (*Client) Send

func (c *Client) Send(p []byte) error

Send a request to the url associated. If the response returns anything other than a StatusOK (200), then it will return an error.

type Error

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

Error is a HTTP error type that allows the sending of errors correctly.

func NewError

func NewError(logger log.Logger) Error

NewError creates a new Error with a logger.

func (Error) BadRequest

func (e Error) BadRequest(w http.ResponseWriter, r *http.Request, err string)

BadRequest to the request with an HTTP 400 bad request error.

func (Error) Error

func (e Error) Error(w http.ResponseWriter, err string, code int)

Error replies to the request with the specified error message and HTTP code. It does not otherwise end the request; the caller should ensure no further writes are done to w. The error message should be application/json.

func (Error) InternalServerError

func (e Error) InternalServerError(w http.ResponseWriter, r *http.Request, err string)

InternalServerError to the request with an HTTP 500 bad request error.

func (Error) NotFound

func (e Error) NotFound(w http.ResponseWriter, r *http.Request)

NotFound replies to the request with an HTTP 404 not found error.

Jump to

Keyboard shortcuts

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