Documentation
¶
Index ¶
- func GetOptionalStringFromVars(name string, args map[string]string, result_Out *string) bool
- func GetStringFromValues(name string, args url.Values, result_Out *string) error
- func RegisterQuerylessGet[ContextType IQuerylessCallContext[DataType], DataType any](router *mux.Router, functionName string, ...)
- func RegisterQuerylessPost[ContextType IQuerylessCallContext[DataType], BodyType any, DataType any](router *mux.Router, functionName string, ...)
- func RegisterSingleStageRoute[ContextType ISingleStageCallContext[DataType], DataType any](router *mux.Router, functionName string, ...)
- func ValidateArg[ArgType any](name string, args map[string]string, impl ArgValidator[ArgType], ...) error
- func ValidateOptionalArg[ArgType any](name string, args map[string]string, impl ArgValidator[ArgType], ...) error
- type ArgValidator
- type IContextFactory
- type IQuerylessCallContext
- type IQuerylessGetContextFactory
- type IQuerylessPostContextFactory
- type ISingleStageCallContext
- type ISingleStageCallContextFactory
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetOptionalStringFromVars ¶
Gets an optional string argument from the provided vars list
func GetStringFromValues ¶
Gets a string argument, ensuring that it exists in the provided vars list
func RegisterQuerylessGet ¶
func RegisterQuerylessGet[ContextType IQuerylessCallContext[DataType], DataType any]( router *mux.Router, functionName string, factory IQuerylessGetContextFactory[ContextType, DataType], serviceProvider *services.ServiceProvider, )
Registers a new route with the router, which will invoke the provided factory to create and execute the context for the route when it's called via GET; use this for typical general-purpose calls
func RegisterQuerylessPost ¶
func RegisterQuerylessPost[ContextType IQuerylessCallContext[DataType], BodyType any, DataType any]( router *mux.Router, functionName string, factory IQuerylessPostContextFactory[ContextType, BodyType, DataType], serviceProvider *services.ServiceProvider, )
Registers a new route with the router, which will invoke the provided factory to create and execute the context for the route when it's called via POST; use this for typical general-purpose calls
func RegisterSingleStageRoute ¶
func RegisterSingleStageRoute[ContextType ISingleStageCallContext[DataType], DataType any]( router *mux.Router, functionName string, factory ISingleStageCallContextFactory[ContextType, DataType], serviceProvider *services.ServiceProvider, )
Registers a new route with the router, which will invoke the provided factory to create and execute the context for the route when it's called; use this for typical general-purpose calls
func ValidateArg ¶
func ValidateArg[ArgType any](name string, args map[string]string, impl ArgValidator[ArgType], result_Out *ArgType) error
Validates an argument, ensuring it exists and can be converted to the required type
func ValidateOptionalArg ¶
func ValidateOptionalArg[ArgType any](name string, args map[string]string, impl ArgValidator[ArgType], result_Out *ArgType, exists_Out *bool) error
Validates an optional argument, converting to the required type if it exists
Types ¶
type ArgValidator ¶
Function for validating an argument (wraps the old CLI validators)
type IContextFactory ¶
Context factories can implement this generally so they can register themselves with an HTTP router.
type IQuerylessCallContext ¶
type IQuerylessCallContext[DataType any] interface { // Prepare the response data in whatever way the context needs to do //PrepareData(data *DataType, opts *bind.TransactOpts) error PrepareData(data *DataType) error }
Wrapper for callbacks used by call runners that simply run without following a structured pattern of querying the chain. This is the most general form of context and can be used by anything as it doesn't add any scaffolding. Structs implementing this will handle the caller-specific functionality.
type IQuerylessGetContextFactory ¶
type IQuerylessGetContextFactory[ContextType IQuerylessCallContext[DataType], DataType any] interface { // Create the context for the route Create(args url.Values) (ContextType, error) }
Interface for queryless call context factories that handle GET calls. These will be invoked during route handling to create the unique context for the route.
type IQuerylessPostContextFactory ¶
type IQuerylessPostContextFactory[ContextType IQuerylessCallContext[DataType], BodyType any, DataType any] interface { // Create the context for the route Create(body BodyType) (ContextType, error) }
Interface for queryless call context factories that handle POST requests. These will be invoked during route handling to create the unique context for the route
type ISingleStageCallContext ¶
type ISingleStageCallContext[DataType any] interface { // Initialize the context with any bootstrapping, requirements checks, or bindings it needs to set up Initialize() error // Used to get any supplemental state required during initialization - anything in here will be fed into an rp.Query() multicall GetState(mc *batch.MultiCaller) // Prepare the response data in whatever way the context needs to do //PrepareData(data *DataType, opts *bind.TransactOpts) error PrepareData(data *DataType) error }
Wrapper for callbacks used by call runners that follow a common single-stage pattern: Create bindings, query the chain, and then do whatever else they want. Structs implementing this will handle the caller-specific functionality.
type ISingleStageCallContextFactory ¶
type ISingleStageCallContextFactory[ContextType ISingleStageCallContext[DataType], DataType any] interface { // Create the context for the route Create(args url.Values) (ContextType, error) }
Interface for single-stage call context factories - these will be invoked during route handling to create the unique context for the route