client

package
v1.0.0-beta2 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2017 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(info auth.CreateAuthInfo, middleware ...OutboundMiddleware) *http.Client

New creates an http.Client that includes 2 extra outbound middleware: tracing and auth they are going to be applied in following order: tracing, auth, remaining outbound middleware and only if all of them passed the request is going to be send. Client is safe to use by multiple go routines, if global tracer is not changed.

Types

type Executor

type Executor interface {
	Execute(r *http.Request) (resp *http.Response, err error)
}

Executor executes the http request. Execute must be safe to use by multiple go routines

type OutboundMiddleware

type OutboundMiddleware interface {
	Handle(r *http.Request, next Executor) (resp *http.Response, err error)
}

OutboundMiddleware applies outbound middleware on client requests and such as adding tracing to request's context. Outbound middleware must call next.Execute() at most once, calling it twice and more will lead to an undefined behavior

type OutboundMiddlewareFunc

type OutboundMiddlewareFunc func(r *http.Request, next Executor) (resp *http.Response, err error)

OutboundMiddlewareFunc is an adaptor to call normal functions to apply outbound middleware.

func (OutboundMiddlewareFunc) Handle

func (f OutboundMiddlewareFunc) Handle(r *http.Request, next Executor) (resp *http.Response, err error)

Handle implements Handle from the OutboundMiddleware interface and simply delegates to the function

Jump to

Keyboard shortcuts

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