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 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().
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ServerBuilder
impl !RefUnwindSafe for ServerBuilder
impl Send for ServerBuilder
impl Sync for ServerBuilder
impl Unpin for ServerBuilder
impl !UnwindSafe for ServerBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more