http

package
v0.0.0-...-6939b5c Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2015 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AfterFunc

type AfterFunc func(context.Context, http.ResponseWriter)

AfterFunc may take information from a request context and use it to manipulate a ResponseWriter. AfterFuncs are executed in the handler, after invoking the endpoint but prior to writing a response.

func SetContentType

func SetContentType(contentType string) AfterFunc

SetContentType returns an AfterFunc that sets the Content-Type header to the provided value.

func SetHeader

func SetHeader(key, val string) AfterFunc

SetHeader returns an AfterFunc that sets the specified header on the response.

type BeforeFunc

type BeforeFunc func(context.Context, *http.Request) context.Context

BeforeFunc may take information from an HTTP request and put it into a request context. BeforeFuncs are executed in the handler, prior to invoking the endpoint.

type DecodeFunc

type DecodeFunc func(*http.Request) (interface{}, error)

DecodeFunc converts an HTTP request (transport-domain) to a user request (business-domain). One straightforward DecodeFunc could be something that JSON-decodes the request body to a concrete request type.

type EncodeFunc

type EncodeFunc func(http.ResponseWriter, interface{}) error

EncodeFunc converts a user response (business-domain) to an HTTP response (transport-domain) by encoding the interface to the response writer.

type Server

type Server struct {
	context.Context
	endpoint.Endpoint
	DecodeFunc
	EncodeFunc
	Before []BeforeFunc
	After  []AfterFunc
}

Server wraps an endpoint and implements http.Handler.

func (Server) ServeHTTP

func (b Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements http.Handler.

Jump to

Keyboard shortcuts

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