actix-web-lab
In-progress extractors and middleware for Actix Web.
What Is This Crate?
This crate serves as a preview and test ground for upcoming features and ideas for Actix Web's built in library of extractors, middleware and other utilities.
Any kind of feedback is welcome.
Complete Examples
See the examples folder for some complete examples of items in this crate.
Things To Know About This Crate
- It will never reach v1.0.
- Minimum Supported Rust Version (MSRV) is latest stable at the time of each release.
- Breaking changes will likely happen on most 0.x version bumps.
- Documentation might be limited for some items.
- Items that graduate to Actix Web crate will be marked deprecated here for a reasonable amount of time so you can migrate.
- Migrating will often be as easy as dropping the
_labsuffix from imports when migrating.
Features
Responders
Csv: efficient CSV streaming (docs)NdJson: efficient NDJSON streaming (docs)DisplayStream: efficient line-by-lineDisplaystreaming (docs)Html: (graduated 🎉) basic string wrapper that responds with HTML Content-Type (docs)Cbor: basic CBOR format wrapper with appropriate Content-Type (docs)MessagePack: basic MessagePack format wrapper with appropriate Content-Type (docs)Sse: semantic server-sent events (SSE) responder with a channel-like interface (docs)
Middleware
from_fn: (graduated 🎉) use an async function as a middleware (docs)map_response: use an async function to modify the response (docs)map_response_body: use an async function to modify the response body (docs)RedirectHttps: middleware to redirect traffic to HTTPS if connection is insecure with optional HSTS (docs)RedirectToWww: middleware to redirect traffic towww.if not already there (docs)RedirectToNonWww: middleware to redirect traffic away fromwww.if it's present (docs)ConditionOption: conditional middleware helper (docs)ErrorHandlers: alternative error handler middleware with simpler interface (docs)NormalizePath: alternative path normalizing middleware with redirect option (docs)CatchPanic: catch panics in wrapped handlers and middleware, returning empty 500 responses (docs)PanicReporter: catch panics in wrapped handlers and middleware, returning empty 500 responses (docs)LoadShed: sheds load when the inner service isn't ready (docs)
Extractors
LazyData: app data/state initialized on first use (docs)SwapData: app data/state that can be replaced at runtime (alternative toData<RwLock<T>>) (docs)LocalData: app data/state that uses anRcinternally, avoiding atomic overhead (alternative toData<RwLock<T>>) (docs)ThinData: (graduated 🎉) app data/state for cheaply-cloned types (docs)Json: simplified JSON extractor with const-generic payload limits and error paths (docs)deser_0_10::DeserJson: JSON extractor that uses deser v0.10 with const-generic payload limits and error paths (docs)Path: simplified path parameter extractor that supports destructuring (docs)Query: simplified query-string extractor that can also collect multi-value items (docs)RequestSignature: wraps an extractor and calculates a request signature alongside (docs)BodyLimit: wraps a body extractor and prevents DoS attacks by limiting payload size (docs)Bytes: simplified Bytes extractor with const-generic limits (docs)UrlEncodedForm: URL-encoded form extractor with const-generic payload size limit (docs)Host: Host information taken from either URL or Host header (docs)
Macros
FromRequest: Derive macro to implementFromRequeston an aggregate struct of other extractors (docs)
Headers
CacheControl: Cache-Control typed header with support for modern directives (docs)ClearSiteData: Clear-Site-Data typed header (docs)ContentLength: Content-Length typed header (docs)Forwarded: Proxy and original client info (docs)StrictTransportSecurity: Strict-Transport-Security (HSTS) configuration (docs)
Body Types
channel: a simple channel-like body type with a sender side that can be used from another thread (docs)writer: a simpleAsyncWritebody type (docs)
Services
Redirect: (graduated 🎉) simple redirects (docs)spa: Easy Single-page Application (SPA) service (docs)
Route Guards
Acceptable: (graduated 🎉) verifies that anAcceptheader is present and it contains a compatible MIME type (docs)
Test Utilities
test_request: constructTestRequestusing an HTTP-like DSL (docs)assert_response_matches: quickly write tests that check various parts of aServiceResponse(docs)
Other Utilities
fork_request_payload: effectively clone a request payload (docs)
Things To Know About This Crate
- It will never reach v1.0.
- Minimum Supported Rust Version (MSRV) is latest stable at the time of each release.
- Breaking changes will likely happen on most 0.x version bumps.
- Documentation might be limited for some items.
- Items that graduate to Actix Web crate will be marked deprecated here for a reasonable amount of time so you can migrate.
- Migrating will often be as easy as dropping the
_labsuffix from imports.