http

package
v0.0.54 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2024 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeriveRegisteredPath

func DeriveRegisteredPath(request *http.Request, ps httprouter.Params) string

func DoesAccept

func DoesAccept(accepts []ContentType, input ContentType) bool

func ValidateContentType

func ValidateContentType(contentType ContentType, accepting []ContentType) error

func WrappedHandler

func WrappedHandler(log logrus.FieldLogger, metrics *Metrics, handler func(ctx context.Context, r *http.Request, p httprouter.Params, contentType ContentType) (*Response, error)) httprouter.Handle

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 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 ContentTypeResolver func() ([]byte, error)

type ContentTypeResolvers

type ContentTypeResolvers map[ContentType]ContentTypeResolver

type ErrorContainer

type ErrorContainer struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

type EthereumSpec

type EthereumSpec struct {
	SecondsPerSlot uint64    `json:"seconds_per_slot"`
	SlotsPerEpoch  uint64    `json:"slots_per_epoch"`
	GenesisTime    time.Time `json:"genesis_time"`
}

type Metrics

type Metrics struct {
	// contains filtered or unexported fields
}

func NewMetrics

func NewMetrics(enabled bool, namespace string) Metrics

func (Metrics) ObserveRequest

func (m Metrics) ObserveRequest(method, path string)

func (Metrics) ObserveResponse

func (m Metrics) ObserveResponse(method, path, code, encoding string, duration time.Duration)

type Response

type Response 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) *Response

func NewInternalServerErrorResponse

func NewInternalServerErrorResponse(resolvers ContentTypeResolvers) *Response

func NewNotFoundResponse

func NewNotFoundResponse(resolvers ContentTypeResolvers) *Response

func NewSuccessResponse

func NewSuccessResponse(resolvers ContentTypeResolvers) *Response

func NewUnsupportedMediaTypeResponse

func NewUnsupportedMediaTypeResponse(resolvers ContentTypeResolvers) *Response

func (*Response) AddExtraData

func (r *Response) AddExtraData(key string, value interface{})

func (Response) MarshalAs

func (r Response) MarshalAs(contentType ContentType) ([]byte, error)

func (Response) SetCacheControl

func (r Response) SetCacheControl(v string)

func (Response) SetEtag

func (r Response) SetEtag(etag string)

type V1GetEthereumNowRequest

type V1GetEthereumNowRequest struct {
}

type V1GetEthereumNowResponse

type V1GetEthereumNowResponse struct {
	Slot  uint64 `json:"slot"`
	Epoch uint64 `json:"epoch"`
}

type V1GetEthereumSpecRequest

type V1GetEthereumSpecRequest struct {
}

V1 // Ethereum

type V1GetEthereumSpecResponse

type V1GetEthereumSpecResponse struct {
	NetworkName string       `json:"network_name"`
	Spec        EthereumSpec `json:"spec"`
}

type V1GetFrameRequest

type V1GetFrameRequest struct {
}

// Frames

type V1GetFrameResponse

type V1GetFrameResponse struct {
	Frame *types.Frame `json:"frame"`
}

type V1MetadataListEpochsRequest

type V1MetadataListEpochsRequest struct {
	Filter     *service.FrameFilter      `json:"filter"`
	Pagination *service.PaginationCursor `json:"pagination"`
}

type V1MetadataListEpochsResponse

type V1MetadataListEpochsResponse struct {
	Epochs     []phase0.Epoch              `json:"epochs"`
	Pagination *service.PaginationResponse `json:"pagination"`
}

type V1MetadataListLabelsRequest

type V1MetadataListLabelsRequest struct {
	Filter     *service.FrameFilter      `json:"filter"`
	Pagination *service.PaginationCursor `json:"pagination"`
}

type V1MetadataListLabelsResponse

type V1MetadataListLabelsResponse struct {
	Labels     []string                    `json:"labels"`
	Pagination *service.PaginationResponse `json:"pagination"`
}

type V1MetadataListNodesRequest

type V1MetadataListNodesRequest struct {
	Filter     *service.FrameFilter      `json:"filter"`
	Pagination *service.PaginationCursor `json:"pagination"`
}

type V1MetadataListNodesResponse

type V1MetadataListNodesResponse struct {
	Nodes      []string                    `json:"nodes"`
	Pagination *service.PaginationResponse `json:"pagination"`
}

type V1MetadataListRequest

type V1MetadataListRequest struct {
	Filter     *service.FrameFilter      `json:"filter"`
	Pagination *service.PaginationCursor `json:"pagination"`
}

// Metadata

type V1MetadataListResponse

type V1MetadataListResponse struct {
	Frames     []*types.FrameMetadata      `json:"frames"`
	Pagination *service.PaginationResponse `json:"pagination"`
}

type V1MetadataListSlotsRequest

type V1MetadataListSlotsRequest struct {
	Filter     *service.FrameFilter      `json:"filter"`
	Pagination *service.PaginationCursor `json:"pagination"`
}

type V1MetadataListSlotsResponse

type V1MetadataListSlotsResponse struct {
	Slots      []phase0.Slot               `json:"slots"`
	Pagination *service.PaginationResponse `json:"pagination"`
}

Jump to

Keyboard shortcuts

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