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
- func WriteSSZResponse(w http.ResponseWriter, data []byte) error
- type BeaconError
- 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 Metrics
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.
func WriteSSZResponse ¶
func WriteSSZResponse(w http.ResponseWriter, data []byte) error
Types ¶
type BeaconError ¶
type ContentType ¶
type ContentType int
const ( ContentTypeUnknown ContentType = iota ContentTypeJSON ContentTypeYAML ContentTypeSSZ )
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 { 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)
func (HTTPResponse) SetEthConsensusVersion ¶ added in v0.23.0
func (r HTTPResponse) SetEthConsensusVersion(version 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. All http-level concerns should be handled in this package, with the "namespaces" (eth/checkpointz) handling all business logic and dealing with concrete types.
func NewHandler ¶
func NewHandler(log logrus.FieldLogger, beac beacon.FinalityProvider, config *beacon.Config) *Handler
type Metrics ¶
type Metrics struct {
// contains filtered or unexported fields
}
func NewMetrics ¶
func (Metrics) ObserveRequest ¶
Click to show internal directories.
Click to hide internal directories.