Expand description
The facades — static proxies onto container-resolved services.
ⓘ
use rainier_framework::facades::{Config, DB, Event, Queue};
let name: String = Config::instance().get_or("app.name", "Rainier".into());
Event::instance().dispatch(UserRegistered { id }).await?;
Queue::instance().dispatch(SendWelcomeEmail { id }).await?;
let posts: Vec<Post> = DB::instance().fetch_all(prepared).await?;Every call resolves through the container, so rebinding the accessor swaps
what every facade call sees — which is how a test installs a fake without a
separate swap mechanism.
The convenience is real and so is the cost: a facade hides a dependency that a constructor argument would have made visible. Reach for one in application code and route closures; take the service as an argument in anything you intend to unit-test.
Structs§
- Broadcast
- Broadcasting to WebSocket channels.
- Cache
- The cache.
- Config
- The configuration repository.
- Crypt
- Encryption and signing.
- DB
- The database handle.
- Event
- The event dispatcher — Rainier’s hook bus.
- The mailer.
- Middleware
- The middleware registry.
- Notify
- Notifications.
- Queue
- The queue dispatcher.
- Session
- The session store and its settings.
- Storage
- File storage.
- Url
- URL generation for named routes.
- View
- The view engine.
- Views
- The application’s view engine, as a container-storable value.