...

Source file src/github.com/go-kit/kit/transport/http/encode_decode.go

Documentation: github.com/go-kit/kit/transport/http

     1  package http
     2  
     3  import (
     4  	"context"
     5  	"net/http"
     6  )
     7  
     8  // DecodeRequestFunc extracts a user-domain request object from an HTTP
     9  // request object. It's designed to be used in HTTP servers, for server-side
    10  // endpoints. One straightforward DecodeRequestFunc could be something that
    11  // JSON decodes from the request body to the concrete request type.
    12  type DecodeRequestFunc func(context.Context, *http.Request) (request interface{}, err error)
    13  
    14  // EncodeRequestFunc encodes the passed request object into the HTTP request
    15  // object. It's designed to be used in HTTP clients, for client-side
    16  // endpoints. One straightforward EncodeRequestFunc could be something that JSON
    17  // encodes the object directly to the request body.
    18  type EncodeRequestFunc func(context.Context, *http.Request, interface{}) error
    19  
    20  // CreateRequestFunc creates an outgoing HTTP request based on the passed
    21  // request object. It's designed to be used in HTTP clients, for client-side
    22  // endpoints. It's a more powerful version of EncodeRequestFunc, and can be used
    23  // if more fine-grained control of the HTTP request is required.
    24  type CreateRequestFunc func(context.Context, interface{}) (*http.Request, error)
    25  
    26  // EncodeResponseFunc encodes the passed response object to the HTTP response
    27  // writer. It's designed to be used in HTTP servers, for server-side
    28  // endpoints. One straightforward EncodeResponseFunc could be something that
    29  // JSON encodes the object directly to the response body.
    30  type EncodeResponseFunc func(context.Context, http.ResponseWriter, interface{}) error
    31  
    32  // DecodeResponseFunc extracts a user-domain response object from an HTTP
    33  // response object. It's designed to be used in HTTP clients, for client-side
    34  // endpoints. One straightforward DecodeResponseFunc could be something that
    35  // JSON decodes from the response body to the concrete response type.
    36  type DecodeResponseFunc func(context.Context, *http.Response) (response interface{}, err error)
    37  

View as plain text