Documentation ¶
Index ¶
- func HandleResponse[DataType any](context IRequesterContext, resp *http.Response, path string, err error) (*types.ApiResponse[DataType], error)
- func MakeBatchArg[DataType BatchInputType](input []DataType) string
- func RawGetRequest[DataType any](context IRequesterContext, path string, params map[string]string) (*types.ApiResponse[DataType], error)
- func RawPostRequest[DataType any](context IRequesterContext, path string, body string) (*types.ApiResponse[DataType], error)
- func SendGetRequest[DataType any](r IRequester, method string, requestName string, args map[string]string) (*types.ApiResponse[DataType], error)
- func SendPostRequest[DataType any](r IRequester, method string, requestName string, body any) (*types.ApiResponse[DataType], error)
- type BatchInputType
- type IRequester
- type IRequesterContext
- type NetworkRequesterContext
- type UnixRequesterContext
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HandleResponse ¶
func HandleResponse[DataType any](context IRequesterContext, resp *http.Response, path string, err error) (*types.ApiResponse[DataType], error)
Processes a response to a request
func MakeBatchArg ¶
func MakeBatchArg[DataType BatchInputType](input []DataType) string
Converts an array of inputs into a comma-delimited string
func RawGetRequest ¶
func RawGetRequest[DataType any](context IRequesterContext, path string, params map[string]string) (*types.ApiResponse[DataType], error)
Submit a GET request to the API server
func RawPostRequest ¶
func RawPostRequest[DataType any](context IRequesterContext, path string, body string) (*types.ApiResponse[DataType], error)
Submit a POST request to the API server
func SendGetRequest ¶
func SendGetRequest[DataType any](r IRequester, method string, requestName string, args map[string]string) (*types.ApiResponse[DataType], error)
Submit a GET request to the API server
func SendPostRequest ¶
func SendPostRequest[DataType any](r IRequester, method string, requestName string, body any) (*types.ApiResponse[DataType], error)
Submit a POST request to the API server
Types ¶
type BatchInputType ¶
type BatchInputType interface { uint64 | common.Address | beacon.ValidatorPubkey }
Types that can be batched into a comma-delmited string
type IRequester ¶
type IRequester interface { // The human-readable requester name (for logging) GetName() string // The name of the subroute to send requests to GetRoute() string // Context to hold settings and utilities the requester should use GetContext() IRequesterContext }
IRequester is an interface for making HTTP requests to a specific subroute on the NMC server
type IRequesterContext ¶ added in v0.3.1
type IRequesterContext interface { // Get the base of the address used for submitting server requests GetAddressBase() string // Get the logger for the context GetLogger() *slog.Logger // Set the logger for the context SetLogger(*slog.Logger) // Send an HTTP request to the server SendRequest(request *http.Request) (*http.Response, error) }
IRequester is an interface for making HTTP requests to a specific subroute on the NMC server
type NetworkRequesterContext ¶ added in v0.3.1
type NetworkRequesterContext struct {
// contains filtered or unexported fields
}
The context passed into a requester
func NewNetworkRequesterContext ¶ added in v0.3.1
func NewNetworkRequesterContext(apiUrl *url.URL, log *slog.Logger, tracer *httptrace.ClientTrace) *NetworkRequesterContext
Creates a new API client requester context for network-based traceOpts is optional. If nil, it will not be used.
func (*NetworkRequesterContext) GetAddressBase ¶ added in v0.3.1
func (r *NetworkRequesterContext) GetAddressBase() string
Get the base of the address used for submitting server requests
func (*NetworkRequesterContext) GetLogger ¶ added in v0.3.1
func (r *NetworkRequesterContext) GetLogger() *slog.Logger
Get the logger for the context
func (*NetworkRequesterContext) SendRequest ¶ added in v0.3.1
Send an HTTP request to the server
func (*NetworkRequesterContext) SetLogger ¶ added in v0.3.1
func (r *NetworkRequesterContext) SetLogger(logger *slog.Logger)
Set the logger for the context
type UnixRequesterContext ¶ added in v0.3.1
type UnixRequesterContext struct {
// contains filtered or unexported fields
}
The context passed into a requester
func NewUnixRequesterContext ¶ added in v0.3.1
func NewUnixRequesterContext(baseRoute string, socketPath string, log *slog.Logger) *UnixRequesterContext
Creates a new API client requester context
func (*UnixRequesterContext) GetAddressBase ¶ added in v0.3.1
func (r *UnixRequesterContext) GetAddressBase() string
Get the base of the address used for submitting server requests
func (*UnixRequesterContext) GetLogger ¶ added in v0.3.1
func (r *UnixRequesterContext) GetLogger() *slog.Logger
Get the logger for the context
func (*UnixRequesterContext) SendRequest ¶ added in v0.3.1
Send an HTTP request to the server
func (*UnixRequesterContext) SetLogger ¶ added in v0.3.1
func (r *UnixRequesterContext) SetLogger(logger *slog.Logger)
Set the logger for the context