pub struct ServerBuilder { /* private fields */ }Expand description
Implementations§
Source§impl ServerBuilder
impl ServerBuilder
Sourcepub fn with_link_service(self, service: impl LinkService + 'static) -> Self
pub fn with_link_service(self, service: impl LinkService + 'static) -> Self
Set the link service (required)
Sourcepub fn with_custom_routes(self, routes: Router) -> Self
pub fn with_custom_routes(self, routes: Router) -> Self
Add custom routes to the server
Use this to add routes that don’t fit the CRUD pattern, such as:
- Authentication endpoints (/login, /logout)
- OAuth flows (/oauth/token, /oauth/callback)
- Webhooks (/webhooks/stripe)
- Custom business logic endpoints
§Example
use axum::{Router, routing::{post, get}, Json};
use serde_json::json;
let auth_routes = Router::new()
.route("/login", post(login_handler))
.route("/logout", post(logout_handler))
.route("/oauth/token", post(oauth_token_handler));
ServerBuilder::new()
.with_link_service(service)
.with_custom_routes(auth_routes)
.register_module(module)?
.build()?;Sourcepub fn with_event_bus(self, capacity: usize) -> Self
pub fn with_event_bus(self, capacity: usize) -> Self
Enable the event bus for real-time notifications
When enabled, REST/GraphQL handlers will publish events for mutations, and real-time exposures (WebSocket, SSE) can subscribe to receive them.
§Arguments
capacity- Buffer size for the broadcast channel (recommended: 1024)
§Example
ServerBuilder::new()
.with_link_service(service)
.with_event_bus(1024)
.register_module(module)?
.build_host()?;Sourcepub fn with_sink_registry(self, registry: SinkRegistry) -> Self
pub fn with_sink_registry(self, registry: SinkRegistry) -> Self
Provide a pre-built sink registry (overrides auto-wiring from config)
Use this when you need full control over which sinks are registered.
If not provided and sinks is present in config, sinks are auto-wired.
Sourcepub fn with_notification_store(self, store: Arc<NotificationStore>) -> Self
pub fn with_notification_store(self, store: Arc<NotificationStore>) -> Self
Provide a pre-built notification store
If not provided, one is auto-created when InApp sinks are configured.
Sourcepub fn with_device_token_store(self, store: Arc<DeviceTokenStore>) -> Self
pub fn with_device_token_store(self, store: Arc<DeviceTokenStore>) -> Self
Provide a pre-built device token store
If not provided, one is auto-created when sinks are configured.
Sourcepub fn with_preferences_store(
self,
store: Arc<NotificationPreferencesStore>,
) -> Self
pub fn with_preferences_store( self, store: Arc<NotificationPreferencesStore>, ) -> Self
Provide a pre-built notification preferences store
If not provided, one is auto-created when sinks are configured.
Sourcepub fn register_module(self, module: impl Module + 'static) -> Result<Self>
pub fn register_module(self, module: impl Module + 'static) -> Result<Self>
Register a module
This will:
- Load the module’s configuration
- Register all entities from the module
- Store the module for entity fetching
Sourcepub fn build_host(self) -> Result<ServerHost>
pub fn build_host(self) -> Result<ServerHost>
Build the transport-agnostic host
This generates a ServerHost that can be used with any exposure type
(REST, GraphQL, gRPC, etc.).
§Returns
Returns a ServerHost containing all framework state.
Sourcepub fn build(self) -> Result<Router>
pub fn build(self) -> Result<Router>
Build the final REST router
This generates:
- CRUD routes for all registered entities
- Link routes (bidirectional)
- Introspection routes
Note: This is a convenience method that builds the host and immediately
exposes it via REST. For other exposure types, use build_host_arc().