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 {
// The path to the socket to send requests to
SocketPath string
// An HTTP Client for sending requests
Client *http.Client
// Whether or not to print debug logs
DebugMode bool
// Logger to print debug messages to
Log *log.ColorLogger
// The base route for the client to send requests to (<http://<base>/<route>/<method>)
Base string
}
The context passed into a requester
func NewRequesterContext ¶
func NewRequesterContext(baseRoute string, socketPath string, debugMode bool) *RequesterContext
Creates a new API client context
Click to show internal directories.
Click to hide internal directories.