Documentation ¶
Overview ¶
Package http defines the standard interfaces for HTTP server and client.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyMiddleware ¶
func ApplyMiddleware(h http.Handler, mw ...Middleware) http.Handler
ApplyMiddleware applies the provided list of middleware to the HTTP handler h, in order - i.e. the first middleware is applied to the next, which is applied to the next, etc. until the last one which is applied to h.
Types ¶
type Client ¶
type Client interface { // Do executes the request and returns the response or an error. The context // is not part of the signature, as it is part of the HTTP request struct. Do(req *http.Request) (*http.Response, error) }
Client defines the method for an HTTP client.
type Middleware ¶
A Middleware is a function that takes a HTTP handler and returns another HTTP handler, with some behaviour added.
type MockClient ¶
MockClient is a test mock for the Client interface.
type MockServer ¶
type MockServer struct { MountFunc func(string, http.Handler) error ListenAndServeFunc func(context.Context) error }
MockServer is a test mock for the Server interface.
func (*MockServer) ListenAndServe ¶
func (m *MockServer) ListenAndServe(ctx context.Context) error
type Server ¶
type Server interface { // Mount mounts an HTTP handler at the specified path. The exact semantics of // the operation is implementation-specific. Mount(path string, handler http.Handler) error // ListenAndServe starts the HTTP server. The context is used to signal // graceful shutdown of the server when cancelled. It should also be used as // base context for requests, but this is implementation-specific. ListenAndServe(ctx context.Context) error }
Server defines the methods for an HTTP server.
Click to show internal directories.
Click to hide internal directories.