Skip to main content

Crate rust_webx

Crate rust_webx 

Source

Re-exports§

pub use rust_dix;
pub use rust_dix_macros;
pub use hyper;
pub use serde;
pub use serde_json;
pub use tokio;

Macros§

register_handlers

Structs§

AppOptions
Standard application options loaded from appsettings.json.
AppSection
Top-level application section.
AuthorizerSet
A set of IDynamicAuthorizer instances collected from the DI container.
CompressionConfig
Compression configuration.
CompressionMiddleware
Middleware that compresses response bodies with gzip when the client supports it (via Accept-Encoding: gzip) and the response exceeds min_size bytes.
ControllerEndpoint
Endpoint for controller-based methods.
CorsConfig
CORS configuration loaded from appsettings.json.
CorsMiddleware
Built-in CORS middleware.
CorsSection
CORS (Cross-Origin Resource Sharing) section.
DistributedCacheEntryOptions
FieldError
HandlerCache
Runtime registry of compiled handler registrations.
HandlerEntry
A single compiled handler entry in the registry.
HandlerRegistration
Handler registration collected at compile time. Each #[handler] annotation submits one of these to inventory.
HealthCheckEntry
A single health check entry in a registry snapshot.
HealthCheckRegistry
HealthStatus
Host
HostAppBuilder
HostBuilder
HttpContext
Concrete implementation of IHttpContext wrapping a hyper request and response.
HttpRequest
Concrete implementation of IHttpRequest.
HttpResponse
Concrete implementation of IHttpResponse.
HttpStatus
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.
MemoryCache
MetricsSection
HTTP request metrics (GET /metrics Prometheus text when enabled).
MiddlewarePipeline
PagedRequest
PagedResponse
ParamMeta
Metadata about a request parameter for OpenAPI generation.
ProblemDetails
RateLimitMiddleware
RateLimitSection
Per-IP rate limiting (token bucket).
RateLimiter
Inner rate-limiting state shared behind a Mutex.
RequestContext
Scoped operator identity from JWT sub, set by the HTTP dispatch pipeline.
RequestEndpoint
Endpoint that wraps a boxed async handler.
RequestIdMiddleware
Generates a UUID v4 request ID on each request and injects it into the response.
RequestTracing
ResourceAuthorization
Authorization policy that maps route patterns to allowed roles and permissions.
ResponseData
Response data produced by a dispatch function.
RouteDispatch
A dispatch function registered at compile time via the endpoint macros.
RouteEntry
A route entry registered at compile time via #[endpoint] (or its shortcuts #[get]/#[post]/…).
RouteMeta
Route metadata: method + path pattern.
Router
Matchit-based router.
SecurityHeadersMiddleware
Middleware that adds a standard set of security headers to every response.
Server
A fully built server that owns its runtime lifecycle.
ServerHandle
Handle for a running server, allowing programmatic graceful shutdown.
SpaMiddleware
SPA static file middleware.
StaticHtmlEndpoint
Endpoint that serves a static HTML payload.
StaticJsonEndpoint
Endpoint that serves a static JSON payload.
TimingMiddleware
Records a request counter via the after hook.
TlsSection
TLS (Transport Layer Security) section.

Enums§

AppMode
Controls how the framework behaves at startup and at runtime.
CacheError
Error
Framework-wide error type.
HttpMethod
HTTP methods supported by the framework.

Constants§

APIUI_HTML
The embedded HTML for the API docs UI.

Traits§

DistributedCacheExtensions
FromHttpContext
Trait for constructing a request struct from the HTTP context.
IAppOptions
Application options — binds to a section of appsettings.json.
IAuthenticationHandler
Authentication scheme interface.
IAuthorizationPolicy
Authorization policy that checks whether an authenticated user can access a given resource.
IClaims
Claims extracted from an authentication token (JWT, etc.).
IClaimsCarrier
Blanket trait that enables claims injection on request structs.
IClaimsExt
Extension trait that adds claims storage to an IHttpContext.
IDistributedCache
IDynamicAuthorizer
Dynamic authorizer interface — pluggable authorization for protected routes.
IEndpoint
An endpoint handler is the terminal component in the middleware pipeline.
IEventHandler
Handles a single IEventRequest, performing side effects.
IEventRequest
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.
IHostedService
Background service that is started when the host starts and stopped when the host performs a graceful shutdown.
IHttpContext
HTTP context encapsulating the request, response, and service provider for the duration of a single HTTP request.
IHttpRequest
HTTP request abstraction.
IHttpResponse
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.
IPipelineBehavior
Pipeline behavior that wraps around request handling.
IRequest
Marker trait for a request (command or query) carrying a structured response TResponse.
IRequestHandler
Handles a single IRequest<R>, producing its associated response R.
IRouter
Router that matches incoming HTTP requests to registered endpoints.
IServiceCollectionExt
Extension methods for rust_dix::ServiceCollection to enable framework-level service registration patterns.
ScopeFactory
工厂 trait:创建独立 scope。可注入 singleton 服务按需创建 scope。

Functions§

app_base
解析应用基准目录。优先级见模块文档。
bind_config
Bind a section of the config JSON to a deserializable type.
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.
collect_authorizers
Result from collecting IDynamicAuthorizer instances from DI. None means no authorizers are registered (pass-through mode).
compress_gzip
Compress a byte buffer using gzip at the given compression level (0-9).
format_route_diagnostics
Human-readable route/handler diagnostic report (no tracing dependency).
generate_openapi_spec
Generate an OpenAPI 3.0.3 specification from registered routes.
global_provider
Get the global service provider. Used by #[handler] factories when the handler struct has #[inject_attr] for DI-based construction.
init_jwt_secret
Initialize the global JWT encoding secret from the configured secret. This is called automatically by .add_authentication() on the HostBuilder, 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)。
orphan_handlers
Request types registered via #[handler] without a matching route.
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.
set_global_provider
Set the global service provider. Called once at Host::build() time.
should_scan_endpoints
write_json_response
Helper: build a JSON response by serializing a value and writing it.

Type Aliases§

BoxedNextFn
Type-erased continuation function for pipeline behaviors.
BoxedPipelineFuture
Boxed future returned by a pipeline behavior step.
HandlerFn
Boxed final handler function type.
HandlerRegistry
Preferred name for HandlerCache — emphasizes registry semantics over caching.
HealthCheckFn
Json
Type alias for JSON responses in controller methods.
Result
Shorthand for Result<T, Error>.

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.
endpoint
Full form: marks an IRequest impl with HTTP method and route path.
from_body
Marks a field or parameter as deserialized from the JSON request body.
from_query
Marks a field or parameter as extracted from the query string.
from_route
Marks a field or parameter as extracted from the route path.
get
Shortcut: registers an IRequest impl at GET /path.
handler
Auto-registers an IRequestHandler implementation at compile time via inventory.
inject
module
post
Shortcut: registers an IRequest impl at POST /path.
put
Shortcut: registers an IRequest impl at PUT /path.

Derive Macros§

Inject