Documentation ¶
Index ¶
- func HandleResponse[DataType any](context *RequesterContext, resp *http.Response, path string, err error) (*types.ApiResponse[DataType], error)
- func MakeBatchArg[DataType BatchInputType](input []DataType) string
- func RawGetRequest[DataType any](context *RequesterContext, path string, params map[string]string) (*types.ApiResponse[DataType], error)
- func RawPostRequest[DataType any](context *RequesterContext, 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 RequesterContext
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HandleResponse ¶
func HandleResponse[DataType any](context *RequesterContext, 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 *RequesterContext, 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 *RequesterContext, 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() *RequesterContext }
IRequester is an interface for making HTTP requests to a specific subroute on the NMC server
type RequesterContext ¶
type RequesterContext struct {
// contains filtered or unexported fields
}
The context passed into a requester
func NewRequesterContext ¶
func NewRequesterContext(baseRoute string, socketPath string, log *slog.Logger) *RequesterContext
Creates a new API client requester context
func (*RequesterContext) SetLogger ¶ added in v0.2.0
func (r *RequesterContext) SetLogger(logger *slog.Logger)
Set the logger for the context
Click to show internal directories.
Click to hide internal directories.