httptools

package
v0.0.0-...-affaa53 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2019 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultHTTPRequestProvider

func DefaultHTTPRequestProvider(method, url string, body io.Reader) (*http.Request, error)

DefaultHTTPRequestProvider returns a default http.Request with the given method, url and body

func RequestLogger

func RequestLogger(label string, h http.Handler) http.Handler

RequestLogger creates an http.Handler function with a default info logger

func RespondWithBody

func RespondWithBody(w http.ResponseWriter, events subscribed.Events, httpCode int)

RespondWithBody sends http response with json body

func RespondWithErrorAndLog

func RespondWithErrorAndLog(e error, w http.ResponseWriter)

RespondWithErrorAndLog logs error and sends http response with error json body

Types

type HTTPClient

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

An HTTPClient represents an interface type of HTTPClient that encapsulates a 'Do' function which takes an http.Request and returns an http.Response

func DefaultHTTPClientProvider

func DefaultHTTPClientProvider() HTTPClient

DefaultHTTPClientProvider returns a default HTTPClient implementation

type HTTPClientProvider

type HTTPClientProvider func() HTTPClient

An HTTPClientProvider represents a function type that returns an HTTPClient

type HTTPRequestProvider

type HTTPRequestProvider func(method, url string, body io.Reader) (*http.Request, error)

An HTTPRequestProvider represents a function type that returns an http.Request

Jump to

Keyboard shortcuts

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