Expand description
Umbrella crate for the rust-webx framework (package rust-webx, imported as
webx).
Re-exports the whole framework so applications need a single dependency:
[dependencies]
rust-webx = "0.5"ⓘ
use webx::*;The dependency name is rust-webx; the import name is webx. The same
applies to the sub-crates (rust-webx-core → webx_core,
rust-webx-host → webx_host, rust-webx-macros → webx_macros,
rust-webx-spa → webx_spa, rust-webx-openapi → webx_openapi).
Re-exports§
pub use rust_dix;pub use rust_dix_macros;pub use hyper;pub use serde;pub use serde_json;pub use tokio;
Modules§
- assets
- Files compiled into the executable by
#[webx::main(embed)], read by path. - spa
- Static file hosting, including files compiled into the executable.
Macros§
- register_
handlers Deprecated
Structs§
- AppOptions
- Standard application options loaded from appsettings.json.
- AppSection
- Top-level application section.
- Authorizer
Set - A set of
IDynamicAuthorizerinstances collected from the DI container. - Byte
Range - An inclusive byte range, as requested by a
Rangeheader. - Compression
Config - Compression configuration.
- Compression
Middleware - Middleware that compresses response bodies with gzip when the client
supports it (via
Accept-Encoding: gzip) and the response exceedsmin_sizebytes. - Controller
Endpoint - Endpoint for controller-based methods.
- Cors
Config - CORS configuration loaded from appsettings.json.
- Cors
Middleware - Built-in CORS middleware.
- Cors
Section - CORS (Cross-Origin Resource Sharing) section.
- Dispatch
Runtime - Provider + handler registry for one host instance.
- Distributed
Cache Entry Options - Field
Error - File
Body - A file response — the rust-webx counterpart of ASP.NET Core’s
File(...)/PhysicalFile(...)/Results.File(...). - Form
Deserializer - Deserializer over a
MultipartForm. - Form
Error - Error produced while binding a
multipart/form-datarequest. - Form
Field - One text part of a multipart form.
- Form
File - One file part of a
multipart/form-datarequest. - Form
File Builder - Incrementally builds a
FormFilewhile a multipart part streams in. - Handler
Cache - Runtime registry of compiled handler registrations.
- Handler
Entry - A single compiled handler entry in the registry.
- Handler
Registration - Handler registration collected at compile time.
Each
#[handler]annotation submits one of these to inventory. - Health
Check Entry - A single health check entry in a registry snapshot.
- Health
Check Registry - Health
Status - Host
- Host
AppBuilder - Host
Builder - Http
Context - Concrete implementation of IHttpContext wrapping a hyper request and response.
- Http
Request - Concrete implementation of IHttpRequest.
- Http
Response - Concrete implementation of IHttpResponse.
- Http
Status - Common HTTP status codes.
- JwtAuth
- JWT-based authentication handler.
- JwtClaims
- Claims extracted from a JWT token.
- JwtSection
- JWT authentication section.
- Mediator
- Default implementation of IMediator.
- Memory
Cache - Metrics
Section - HTTP request metrics (
GET /metricsPrometheus text when enabled). - Middleware
Pipeline - Multipart
Form - A parsed
multipart/form-databody. - Paged
Request - Paged
Response - Param
Meta - Metadata about a request parameter for OpenAPI generation.
- Problem
Details - Rate
Limit Middleware - Rate
Limit Section - Per-IP rate limiting (token bucket).
- Rate
Limiter - Inner rate-limiting state shared behind a
Mutex. - Request
Context - Scoped operator identity from JWT
sub, set by the HTTP dispatch pipeline. - Request
Endpoint - Endpoint that wraps a boxed async handler.
- Request
IdMiddleware - Generates a UUID v4 request ID on each request and injects it into the response.
- Request
Param Entry - Optional query/path/body metadata for a request type, collected via
#[derive(WebxRequestMeta)]on the request struct. - Request
Tracing - Resource
Authorization - Authorization policy that maps route patterns to allowed roles and permissions.
- Response
Data - The HTTP response produced by an endpoint.
- Route
Dispatch - A dispatch function registered at compile time via the endpoint macros.
- Route
Entry - A route entry registered at compile time via
#[endpoint](or its shortcuts#[get]/#[post]/…). - Route
Meta - Route metadata: method + path pattern.
- Router
- Matchit-based router.
- Security
Headers Middleware - Middleware that adds a standard set of security headers to every response.
- Server
- A fully built server that owns its runtime lifecycle.
- Server
Handle - Handle for a running server, allowing programmatic graceful shutdown.
- SpaMiddleware
- SPA static file middleware.
- Static
Html Endpoint - Endpoint that serves a static HTML payload.
- Static
Json Endpoint - Endpoint that serves a static JSON payload.
- Timing
Middleware - Records a request counter via the
afterhook. - TlsSection
- TLS (Transport Layer Security) section.
Enums§
- AppMode
- Controls how the framework behaves at startup and at runtime.
- Cache
Error - Disposition
- How a file response should be presented.
- Error
- Framework-wide error type.
- File
Source - Where a file response’s bytes come from.
- Http
Method - HTTP methods supported by the framework.
- Response
Body - The body of an HTTP response.
Constants§
- APIUI_
HTML - The embedded HTML for the API docs UI.
- SPOOL_
FILE_ PREFIX - Prefix given to every temporary file the framework writes for an upload.
- STREAM_
BUF_ SIZE - Read/write buffer size used for streamed response bodies and spooled uploads.
Traits§
- Distributed
Cache Extensions - From
Http Context - Trait for constructing a request struct from the HTTP context.
- IApp
Options - Application options — binds to a section of appsettings.json.
- IAuthentication
Handler - Authentication scheme interface.
- IAuthorization
Policy - Authorization policy that checks whether an authenticated user can access a given resource.
- IClaims
- Claims extracted from an authentication token (JWT, etc.).
- IClaims
Carrier - Blanket trait that enables claims injection on request structs.
- IClaims
Ext - Extension trait that adds claims storage to an
IHttpContext. - IDistributed
Cache - IDynamic
Authorizer - Dynamic authorizer interface — pluggable authorization for protected routes.
- IEndpoint
- An endpoint handler is the terminal component in the middleware pipeline.
- IEvent
Handler - Handles a single
IEventRequest, performing side effects. - IEvent
Request - Marker trait for an event (notification) that does not produce a response.
- IHost
- The web host that binds to an address and starts serving HTTP requests.
- IHosted
Service - Background service that is started when the host starts and stopped when the host performs a graceful shutdown.
- IHttp
Context - HTTP context encapsulating the request, response, and service provider for the duration of a single HTTP request.
- IHttp
Request - HTTP request abstraction.
- IHttp
Response - HTTP response abstraction.
- IMediator
- The mediator dispatches requests to their handlers and publishes events to all registered handlers.
- IMiddleware
- Middleware component in the HTTP request pipeline.
- IPipeline
Behavior - Pipeline behavior that wraps around request handling.
- IRequest
- Marker trait for a request (command or query) carrying a structured response
TResponse. - IRequest
Handler - Handles a single
IRequest<R>, producing its associated responseR. - IRouter
- Router that matches incoming HTTP requests to registered endpoints.
- IService
Collection Ext - Extension methods for
rust_dix::ServiceCollectionto enable framework-level service registration patterns. - Scope
Factory - Factory trait for creating independent scopes. Injectable into singleton services that need on-demand scope creation (e.g., background workers). 工厂 trait:创建独立 scope。可注入 singleton 服务按需创建 scope。
- Seekable
Reader - An async reader that can also seek.
Functions§
- app_
base - 解析应用基准目录。优先级见模块文档。
- bind_
config - Bind a section of the config JSON to a deserializable type.
- bind_
form_ request - Bind
Tfrom amultipart/form-databody. - bind_
root - Bind the entire config JSON to a type (for root-level deserialization).
- build_
pipeline_ chain - Build a chain of pipeline behaviors wrapping a terminal handler.
- build_
resource_ policy_ from_ routes - Build a
ResourceAuthorizationpolicy from compile-timeRouteEntrymetadata. - collect_
authorizers - Result from collecting
IDynamicAuthorizerinstances from DI.Nonemeans no authorizers are registered (pass-through mode). - compress_
gzip - Compress a byte buffer using gzip at the given compression level (0-9).
- content_
disposition_ value - Build a
Content-Dispositionheader value (RFC 6266). - dispatch_
provider - Provider for HTTP dispatch and
#[handler(inject)]factories. - duplicate_
handlers - Request types with more than one
#[handler]registration (last wins at runtime). - format_
route_ diagnostics - Human-readable route/handler diagnostic report (no tracing dependency).
- framework_
root - Resolve the Rust-Framework monorepo root for live sibling doc paths.
- generate_
openapi_ spec - Generate an OpenAPI 3.0.3 specification from registered routes.
- global_
provider Deprecated - Deprecated shim: read the process-wide
ServiceProviderfallback. - init_
jwt_ secret - Initialize the global JWT encoding secret from the configured secret.
This is called automatically by
.add_authentication()on theHostBuilder, but can also be called manually if needed. - is_
mediator_ active - jwt_
middleware - Create a JWT authentication middleware from an authentication handler.
- jwt_
secret - Retrieve the global JWT encoding secret previously set via
init_jwt_secret. - load_
appsettings - Load the merged appsettings JSON (base + environment overlay + env overrides).
- log_
startup_ diagnostics - Log route table and warn on orphan routes/handlers.
- looks_
like_ app_ base - 判断给定目录是否为「应用基准目录」(存在
appsettings.json)。 - looks_
like_ framework_ root - Returns true when
dirlooks like the Rust-Framework monorepo root (containsrust-webxand at least one other ecosystem crate). - orphan_
handlers - Request types registered via
#[handler]without a matching route. - orphan_
route_ details - Routes with inventory entries but no matching
#[handler](includes path/method). - orphan_
routes - Request types with a route but no registered handler.
- read_
json_ body - Helper: read JSON from the request body.
- resource_
auth_ middleware - Create a resource-based authorization middleware.
- route_
snapshots - Collect all inventory routes and whether a matching
#[handler]exists. - sanitize_
file_ name - Reduce a client-supplied filename to a safe basename.
- set_
global_ provider Deprecated - Deprecated shim: set a process-wide
ServiceProviderfallback. - set_
spool_ root - Point spooling at
path. - should_
scan_ endpoints - spool_
root - The directory used for spooled uploads.
- try_
deserialize_ from_ params - Try to build a request from merged route + query parameters when
T: DeserializeOwned. - write_
json_ response - Helper: build a JSON response by serializing a value and writing it.
Type Aliases§
- Boxed
Next Fn - Type-erased continuation function for pipeline behaviors.
- Boxed
Pipeline Future - Boxed future returned by a pipeline behavior step.
- Handler
Fn - Boxed final handler function type.
- Handler
Registry - Preferred name for
HandlerCache— emphasizes registry semantics over caching. - Health
Check Fn - Json
- Type alias for JSON responses in controller methods.
- Result
- Shorthand for Result<T, Error>.
- Route
Dispatch Fn - The signature every route dispatch function implements.
Attribute Macros§
- async_
trait - authorize
- Declares authorization requirements on a route.
- claims
- Marks a request struct as carrying authentication claims.
- delete
- Shortcut: registers an IRequest impl at DELETE /path.
- embed_
assets - Include the
OUT_DIRasset table (for integration tests that never runmain). - endpoint
- Full form: marks an IRequest impl with HTTP method and route path.
- get
- Shortcut: registers an IRequest impl at GET /path.
- handler
- Auto-registers an IRequestHandler implementation at compile time via inventory.
- inject
- main
- Application entry — ASP.NET Core
Mainanalogue (#[tokio::main]). - module
- post
- Shortcut: registers an IRequest impl at POST /path.
- put
- Shortcut: registers an IRequest impl at PUT /path.
Derive Macros§
- Inject
- Webx
Request Meta - Registers OpenAPI parameter metadata from
#[from_query]/#[from_route]/#[from_body]/#[from_form]fields.