Documentation
¶
Overview ¶
Package http provide go-kit http transport functions
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EncodeJSONResponse ¶
func EncodeJSONResponse(ctx context.Context, w http.ResponseWriter, response interface{}) error
EncodeJSONResponse is a EncodeResponseFunc that serializes the response as a JSON object to the ResponseWriter. Its works like standard go-lit EncodeJSONResponse but checks Failer and RawResponder interfaces
func MakeJSONRequestDecoder ¶
func MakeJSONRequestDecoder(requestFactory func() interface{}) kithttp.DecodeRequestFunc
MakeJSONRequestDecoder is the universal DecodeRequestFunc creator
Example ¶
kithttp.NewServer(
makeSomeEndpoint(),
MakeJSONRequestDecoder(func() interface{} { return &someRequest{} }),
kithttp.EncodeJSONResponse,
)
func RecoveringMiddleware ¶
RecoveringMiddleware recovers panic and returns error to client
Example ¶
var handler http.Handler
{
handler = kithttp.NewServer(
makeSomeEndpoint(),
MakeJSONRequestDecoder(func() interface{} { return &someRequest{} }),
kithttp.EncodeJSONResponse,
)
handler = RecoveringMiddleware(handler, kithttp.DefaultErrorEncoder)
}
// do something with handler
handler.ServeHTTP(responseWriter, request)
Types ¶
type RawResponder ¶
RawResponder is checked by EncodeJSONResponse. It should return io.Reader to copy it to http.ResponseWriter
Click to show internal directories.
Click to hide internal directories.