pub trait ApiGatewayCapability:
Send
+ Sync
+ 'static {
// Required methods
fn rest_prepare(
&self,
ctx: &GearCtx,
router: Router,
hc_registry: Arc<RestHealthcheckRegistry>,
) -> Result<Router>;
fn rest_finalize(
&self,
ctx: &GearCtx,
router: Router,
hc_registry: Arc<RestHealthcheckRegistry>,
) -> Result<Router>;
fn as_registry(&self) -> &dyn OpenApiRegistry;
}Expand description
API Gateway capability: handles gateway hosting with prepare/finalize phases. Must be sync. Runs during REST phase, but doesn’t start the server.
Required Methods§
Sourcefn rest_prepare(
&self,
ctx: &GearCtx,
router: Router,
hc_registry: Arc<RestHealthcheckRegistry>,
) -> Result<Router>
fn rest_prepare( &self, ctx: &GearCtx, router: Router, hc_registry: Arc<RestHealthcheckRegistry>, ) -> Result<Router>
Prepare a base Router (e.g., global middlewares) and optionally touch OpenAPI meta.
Do NOT start the server here. hc_registry is the runtime’s shared healthcheck
registry, passed explicitly (not via ClientHub, which is for inter-gear clients).
§Errors
Returns an error if router preparation fails.
Sourcefn rest_finalize(
&self,
ctx: &GearCtx,
router: Router,
hc_registry: Arc<RestHealthcheckRegistry>,
) -> Result<Router>
fn rest_finalize( &self, ctx: &GearCtx, router: Router, hc_registry: Arc<RestHealthcheckRegistry>, ) -> Result<Router>
Finalize before start: attach /openapi.json, /docs, health endpoints, persist the Router internally if needed. Do NOT start the server here.
hc_registry is the same registry instance passed to rest_prepare.
§Errors
Returns an error if router finalization fails.
fn as_registry(&self) -> &dyn OpenApiRegistry
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".