server

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2024 License: AGPL-3.0 Imports: 14 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterQuerylessGet

func RegisterQuerylessGet[ContextType IQuerylessCallContext[DataType], DataType any](
	router *mux.Router,
	functionName string,
	factory IQuerylessGetContextFactory[ContextType, DataType],
	logger *slog.Logger,
	serviceProvider services.IModuleServiceProvider,
)

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],
	logger *slog.Logger,
	serviceProvider services.IModuleServiceProvider,
)

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 RegisterSingleStagePost

func RegisterSingleStagePost[ContextType ISingleStageCallContext[DataType], BodyType any, DataType any](
	router *mux.Router,
	functionName string,
	factory ISingleStagePostContextFactory[ContextType, BodyType, DataType],
	logger *slog.Logger,
	serviceProvider services.IModuleServiceProvider,
)

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 ISingleStageGetContextFactory[ContextType, DataType],
	logger *slog.Logger,
	serviceProvider services.IModuleServiceProvider,
)

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

Types

type IQuerylessCallContext

type IQuerylessCallContext[DataType any] interface {
	// Prepare the response data in whatever way the context needs to do
	PrepareData(data *DataType, walletStatus wallet.WalletStatus, opts *bind.TransactOpts) (types.ResponseStatus, 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(walletStatus wallet.WalletStatus) (types.ResponseStatus, error)

	// Used to get any supplemental state required during initialization - anything in here will be fed into an hd.Query() multicall
	GetState(mc *batch.MultiCaller)

	// Prepare the response data in whatever way the context needs to do
	PrepareData(data *DataType, opts *bind.TransactOpts) (types.ResponseStatus, 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 ISingleStageGetContextFactory

type ISingleStageGetContextFactory[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

type ISingleStagePostContextFactory

type ISingleStagePostContextFactory[ContextType ISingleStageCallContext[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

Jump to

Keyboard shortcuts

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