The first thing you notice when porting an ASP.NET Core service to Rust is not the borrow checker.
It's that routing, model binding, and error mapping have become three separate decisions.
You pick a router. You write extractors. You add a response wrapper. You add an error type and a From impl.
None of these is hard. The problem is that they drift.
The route string, the DTO, the validation, and the OpenAPI annotation all describe the same operation, in four places.
rust-webx 2.9.4 takes the ASP.NET Core bet: define the request first, and let the framework attach the rest.
One request type is the endpoint
A minimal endpoint looks like this:
#[derive(WebxRequestMeta)] pub struct GetOrderRequest { #[fromclaim] pub user: IdentityUser, #[frompath] pub id: String, } #[get("/api/orders/{id}")] #[authorize(dynamic, permission = "tenant.order.read")] impl IRequest<OrderModel> for GetOrderRequest {} #[handler(inject)] #[async_trait] impl IRequestHandler<GetOrderRequest, OrderModel> for GetOrderHandler { async fn handle(&mut self, req: GetOrderRequest) -> ActionResult<OrderModel> { load_order(&mut self.ctx, &req).await } } The route macro sits on impl IRequest<T>, not on the struct and not on the handler.
#[derive(WebxRequestMeta)] describes where each field comes from. #[fromclaim] means "take it from the authenticated request", not "parse it from JSON".
At compile time, route metadata and handler registrations are collected through inventory. Host::build() joins them.
If a request type has no handler, the host fails to start.
That is the trade: you cannot ship an endpoint that is half-wired.
The cost is that a missing handler shows up during startup rather than during code review.
Binding is part of the contract
Pagination is a good example because every service has it and every service gets it subtly wrong.
#[derive(WebxRequestMeta)] pub struct ListOrdersRequest { #[fromclaim] pub user: IdentityUser, #[fromquery] pub keyword: Option<String>, #[fromquery(nested)] pub paging: PagedRequest, } #[get("/api/orders")] impl IRequest<PagedResult<OrderModel>> for ListOrdersRequest {} PagedRequest has page and page_size, defaults to 1/20, and returns a 400 with a field path when values are out of range.
The handler does not clamp them again.
The response is a flat PagedResult<T> (items, total, plus success/status/message), not a nested page envelope.
The part that matters for a team is not the field names.
It is that the binding rules live with the request type, so a new endpoint gets the same behavior without copying a helper.
Errors have one carrier
Handlers return ActionResult<T>, which is Result<T, AppError>. Database errors, DI errors, and cursor errors each implement From at their own boundary.
So the handler can use ?:
let order = self.ctx.set::<Order>() .query() .filter(linq!(|o: Order| o.id == req.id)) .first_or_default() .await? .ok_or_else(|| Error::not_found("order not found"))?; Error::not_found maps to 404. Error::validation maps to 400.
For 5xx, the operator text stays in the log and the client only sees public_detail(), which is empty for internal errors.
That contract lives in rust-core, a dependency-light crate shared by rust-webx, rust-ef, and rust-dix.
webx::Error is a re-export, not a second definition. In practice this removes the map_*_error functions that tend to appear in every layered Rust service.
The cost is not zero
Request-as-endpoint is a convention, and conventions cost something.
Every operation needs a request type. For a one-line webhook or a health probe, that feels heavy.
The framework is opinionated about where routes live. If you prefer function-based routing, this will fight you.
Startup validation means assembly errors surface at boot. That is good for correctness and annoying for quick scripts.
The ecosystem is optional, not bundled. WebSocket, payments, and the AI gateway are separate crates.
Realtime state is in-process by default. Multi-instance deployments need shared stores and a transport that supports broadcast.
None of this is hidden.
The framework's own documentation lists the boundaries, including at-most-once broadcast and Kafka's lack of broadcast support.
Run the examples
The repository ships three reference apps: docbit (full-stack with docs and RBAC), dmbit (device/inventory), and imbit (realtime IM with HTTP + WebSocket):
cargo run --manifest-path examples/docbit/Cargo.toml -p docbit-host cargo run --manifest-path examples/imbit/Cargo.toml -p imbit-host imbit listens on port 8090 by default.
Its host tests cover messaging, signaling, recording, browser cookie sessions, logout-driven disconnects, and WebSocket origins.
If you are evaluating the framework, do not start with a benchmark. Start with one existing endpoint.
Rewrite it as a request type plus a handler, then run Host::builder().try_build(). The assembly errors you see in the first ten minutes tell you more than a throughput number.
Repository: https://github.com/Rust-Framework/rust-webx
Book: https://rust-framework.github.io/rust-webx/