Struct actix_web_flash_messages::FlashMessagesFramework [−][src]
pub struct FlashMessagesFramework { /* fields omitted */ }
Expand description
actix-web
middleware providing support for sending and receiving FlashMessage
s.
Use FlashMessagesFramework::builder
to build an instance of FlashMessagesFramework
!
use actix_web_flash_messages::{FlashMessagesFramework, storage::CookieMessageStore};
use actix_web::{HttpServer, App, web, cookie::Key};
#[actix_web::main]
async fn main() {
let signing_key = Key::generate(); // This will usually come from configuration!
let message_store = CookieMessageStore::builder(signing_key).build();
let message_framework = FlashMessagesFramework::builder(message_store).build();
HttpServer::new(move || {
App::new()
.wrap(message_framework.clone())
// [...] your endpoints
})
}
Implementations
pub fn builder<S: FlashMessageStore + 'static>(
storage_backend: S
) -> FlashMessagesFrameworkBuilder
pub fn builder<S: FlashMessageStore + 'static>(
storage_backend: S
) -> FlashMessagesFrameworkBuilder
A fluent API to configure FlashMessagesFramework
.
It takes as input a message store, the only required piece of configuration.
actix-web-flash-messages
provides a cookie-based implementation of flash messages, CookieMessageStore
,
using a signed cookie to store and retrieve messages.
You can provide your own custom message store backend by implementing the FlashMessageStore
trait.
Trait Implementations
impl<S, B> Transform<S, ServiceRequest> for FlashMessagesFramework where
S: Service<ServiceRequest, Response = ServiceResponse<B>, Error = Error>,
S::Future: 'static,
B: MessageBody + 'static,
impl<S, B> Transform<S, ServiceRequest> for FlashMessagesFramework where
S: Service<ServiceRequest, Response = ServiceResponse<B>, Error = Error>,
S::Future: 'static,
B: MessageBody + 'static,
type Response = ServiceResponse<B>
type Response = ServiceResponse<B>
Responses produced by the service.
type Transform = FlashMessagesMiddleware<S>
type Transform = FlashMessagesMiddleware<S>
The TransformService
value created by this factory
Creates and returns a new Transform component, asynchronously
Auto Trait Implementations
impl !RefUnwindSafe for FlashMessagesFramework
impl Send for FlashMessagesFramework
impl Sync for FlashMessagesFramework
impl Unpin for FlashMessagesFramework
impl !UnwindSafe for FlashMessagesFramework
Blanket Implementations
Mutably borrows from an owned value. Read more
pub fn vzip(self) -> V
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more