Documentation
¶
Overview ¶
Package proxy implements the bridge-service reverse proxy component: it exposes the aggkit bridge service REST API on the shared HTTP server and forwards every request to the bridge service of the network selected by the request's network_id query parameter, resolved (and kept fresh) through the bridgeservicefinder.
Index ¶
Constants ¶
const ( // BridgeV1Prefix is the url prefix of the proxied bridge service API. It mirrors // bridgeservice.BridgeV1Prefix (asserted in tests) but is redefined here so the proxy // binary does not import the full bridge service (and its swagger assets) for one constant. BridgeV1Prefix = "/bridge/v1" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Logger aggkitcommon.Logger
}
Config holds the configuration of the bridge-service proxy
type NetworkURLResolver ¶
type NetworkURLResolver interface {
GetURL(networkID uint32) (bridgeservicefinder.NetworkURLs, error)
}
NetworkURLResolver is the slice of the bridgeservicefinder.Finder the proxy needs: the per-network bridge service URL
type RESTServer ¶
type RESTServer struct {
// contains filtered or unexported fields
}
RESTServer owns the shared REST/WS HTTP server of the proxy binary: every component registers its routes on it through Register before Start, and Start only binds the listener when at least one component registered routes
func NewRESTServer ¶
func NewRESTServer(cfg aggkitcommon.RESTConfig, logger aggkitcommon.Logger) *RESTServer
NewRESTServer creates the shared REST server. The listener is not bound until Start
func (*RESTServer) Register ¶
func (s *RESTServer) Register(component aggkitcommon.RoutesRegisterer)
Register registers a component's routes on the shared engine
func (*RESTServer) Start ¶
func (s *RESTServer) Start(ctx context.Context) error
Start binds the configured address and serves requests in the background, shutting down gracefully when ctx is done. It is a no-op if no component registered routes. A bind failure (e.g. port already in use) is returned so the caller can abort startup
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service routes incoming bridge REST requests to the per-network bridge service resolved by the finder. Register it on the shared HTTP server with RegisterRoutes
func New ¶
func New(cfg Config, finder NetworkURLResolver) *Service
New returns an instance of the bridge-service proxy
func (*Service) ForwardHandler ¶
ForwardHandler forwards the request to the bridge service of the network selected by the network_id query parameter, preserving method, path, query and body. It answers 400 on a missing/invalid network_id, 404 when no bridge service is known for the network and 502 when the backend is unreachable
func (*Service) RegisterRoutes ¶
RegisterRoutes registers the proxied bridge service API on router