Documentation ¶
Index ¶
- func DoesAccept(accepts []ContentType, input ContentType) bool
- func ValidateContentType(contentType ContentType, accepting []ContentType) error
- func WriteContentAwareResponse(w http.ResponseWriter, data []byte, contentType ContentType) error
- func WriteErrorResponse(w http.ResponseWriter, msg string, statusCode int) error
- func WriteJSONResponse(w http.ResponseWriter, data []byte) error
- type ContentType
- type ContentTypeResolver
- type ContentTypeResolvers
- type HTTPResponse
- func NewBadRequestResponse(resolvers ContentTypeResolvers) *HTTPResponse
- func NewInternalServerErrorResponse(resolvers ContentTypeResolvers) *HTTPResponse
- func NewSuccessResponse(resolvers ContentTypeResolvers) *HTTPResponse
- func NewUnsupportedMediaTypeResponse(resolvers ContentTypeResolvers) *HTTPResponse
- type Handler
- type JSONRequestBody
- type Metrics
- type StubbiesError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DoesAccept ¶
func DoesAccept(accepts []ContentType, input ContentType) bool
func ValidateContentType ¶
func ValidateContentType(contentType ContentType, accepting []ContentType) error
func WriteContentAwareResponse ¶
func WriteContentAwareResponse(w http.ResponseWriter, data []byte, contentType ContentType) error
func WriteErrorResponse ¶
func WriteErrorResponse(w http.ResponseWriter, msg string, statusCode int) error
func WriteJSONResponse ¶
func WriteJSONResponse(w http.ResponseWriter, data []byte) error
WriteJSONResponse writes a JSON response to the given writer.
Types ¶
type ContentType ¶
type ContentType int
const ( ContentTypeUnknown ContentType = iota ContentTypeJSON )
func DeriveContentType ¶
func DeriveContentType(accept string) ContentType
func NewContentTypeFromRequest ¶
func NewContentTypeFromRequest(r *http.Request) ContentType
func (ContentType) String ¶
func (c ContentType) String() string
type ContentTypeResolver ¶
type ContentTypeResolvers ¶
type ContentTypeResolvers map[ContentType]ContentTypeResolver
type HTTPResponse ¶
type HTTPResponse struct { //nolint:tagliatelle // spec requires this field to be named "status_code" StatusCode int `json:"status_code"` Headers map[string]string `json:"headers"` ExtraData map[string]interface{} // contains filtered or unexported fields }
func NewBadRequestResponse ¶
func NewBadRequestResponse(resolvers ContentTypeResolvers) *HTTPResponse
func NewInternalServerErrorResponse ¶
func NewInternalServerErrorResponse(resolvers ContentTypeResolvers) *HTTPResponse
func NewSuccessResponse ¶
func NewSuccessResponse(resolvers ContentTypeResolvers) *HTTPResponse
func NewUnsupportedMediaTypeResponse ¶
func NewUnsupportedMediaTypeResponse(resolvers ContentTypeResolvers) *HTTPResponse
func (*HTTPResponse) AddExtraData ¶
func (r *HTTPResponse) AddExtraData(key string, value interface{})
func (HTTPResponse) MarshalAs ¶
func (r HTTPResponse) MarshalAs(contentType ContentType) ([]byte, error)
func (HTTPResponse) SetCacheControl ¶
func (r HTTPResponse) SetCacheControl(v string)
func (HTTPResponse) SetEtag ¶
func (r HTTPResponse) SetEtag(etag string)
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler is an API handler that is responsible for negotiating with a HTTP api.
func NewHandler ¶
func NewHandler(log logrus.FieldLogger, conf *exec.Config) *Handler
type JSONRequestBody ¶
type JSONRequestBody struct { ID int `json:"id"` Method string `json:"method"` Params []*json.RawMessage `json:"params"` }
type Metrics ¶
type Metrics struct {
// contains filtered or unexported fields
}
func NewMetrics ¶
func (Metrics) ObserveRequest ¶
type StubbiesError ¶
Click to show internal directories.
Click to hide internal directories.