Expand description
Rainier — a batteries-included MVC framework for Rust.
use rainier::prelude::*;
async fn index() -> &'static str {
"Hello from Rainier"
}
let app = Rainier::new(".")
.with_routes(|router| {
router.get("/", index).name("home");
})
.boot()
.await?;§This crate is a name
Everything here is rainier-framework, re-exported.
The two are the same crate for every purpose except the line in your
Cargo.toml, and they are versioned together — rainier 1.2.3 is
rainier-framework 1.2.3 and nothing else.
Depend on whichever reads better. rainier is shorter and makes
use rainier::prelude::* the obvious first line; rainier-framework says
what it is next to the twenty-odd rainier-* crates it is assembled from.
§Where to start
prelude has what an application uses constantly. The
documentation
is one page per concept, and each page explains the design decisions other
MVC frameworks leave implicit — including the places Rainier deliberately
disagrees with them.
Modules§
- auth
- rainier-auth
- binding
- Route-model binding — an action parameter that is the looked-up model rather than its id.
- bootstrap
- Bootstrapping —
Rainier, the builder that assembles an application. - broadcast
- Broadcasting — an event pushed to a browser, and the authorisation that decides who may listen.
- broadcasting
- The half of broadcasting that needs HTTP: the authorisation endpoint, the socket header, and the notification channel.
- cache
- rainier-cache
- commands
- The commands Rainier ships —
route:list,serve,migrate,queue:work,key:generate. - config
- rainier-config
- console_
kernel - rainier-console
- container
- rainier-container
- crypt
- rainier-crypt
- database
- rainier-database
- drivers
- rainier-drivers
- events
- rainier-events
- facades
- The facades — static proxies onto container-resolved services.
- filesystem
- rainier-filesystem
- groups
- The middleware groups Rainier ships —
webandapi, as functions rather than as keys in a map. - health
- Health checks —
Healthand the endpoint that renders them. - http
- rainier-http
- http_
client - rainier-http-client
- keys
- The configuration keys Rainier itself reads — a typed index of the tree.
- limits
- Rate limits that survive a second replica —
RateLimitsandshared. - rainier-mail
- metrics
- Prometheus metrics — a registry, the text format, and request instrumentation.
- middleware
- rainier-middleware
- notifications
- The notification channel that needs a database.
- notify
- rainier-notify
- observability
- Metrics, tracing and the OpenAPI document, built from configuration.
- openapi
- An OpenAPI 3.1 document, built from the router and the request contracts.
- prelude
- Everything an application file usually wants in scope.
- queue
- rainier-queue
- queued_
listeners - Listeners that go on the queue —
DispatcherExtandFromEvent. - routing
- rainier-routing
- scheduler
- rainier-scheduler
- scheduling
- Scheduling — the tasks and commands that need more than the scheduler crate depends on.
- server
- rainier-server
- session
- rainier-session
- signed
- Signed routes —
SignedUrlsandValidateSignature. - support
- rainier-support
- telemetry
- OpenTelemetry — trace context in, spans out.
- testing
- A test harness —
TestAppandTestResponse. - validation
- rainier-validation
- view
- rainier-view
- websocket
- WebSockets — a connection that stays open, served alongside HTTP.
Macros§
- bind_
executor - Writes the
Connectionimpl for a concrete Rainier ORMExecutor. - facade
- Declare a facade type and its
Facadeimpl. - param_
key - Declare a route-parameter name for
BoundAs.
Structs§
- Application
- The application: a
Containerwith a boot lifecycle, an environment, and a filesystem layout. - Command
Task - A
Taskthat runs a console command. - Health
- A registry of health checks.
- Health
Report - The whole report.
- JobTask
- A
Taskthat dispatches a queued job. - KeyGenerate
Command key:generate— mint an application key.- Migrate
Command migrate— run pending migrations.- Migrate
Rollback Command migrate:rollback— undo the most recent batch of migrations.- Queue
Work Command queue:work— process queued jobs.- Rainier
- Assembles an
Application. - Rate
Limits - The store every shared limiter in this application counts in.
- Route
List Command route:list— print the route table.- Schedule
List Command schedule:list— what is scheduled, and when it next runs.- Schedule
RunCommand schedule:run— run whatever is due this minute, then exit.- Schedule
Work Command schedule:work— the same thing in a loop, for a container.- Serve
Command serve— run the HTTP server.- Signed
Urls - Signed URLs for this application’s named routes.
- TestApp
- A booted application, ready to be asked for responses.
- Test
Response - One response, with its body already read.
- Validate
Signature - Refuses a request whose URL is not signed by this application.
- Views
- The application’s view engine, as a container-storable value.
Traits§
- Dispatcher
Ext listen_queued, on top ofDispatcher.- Facade
- A static proxy onto a container-resolved service.
- From
Event - A job that can be built from an event.
- Schedule
Ext jobandcommand, on top ofSchedule.- Service
Provider - A bundle of related bindings and their boot-time wiring.
Functions§
- console
- A console with every built-in command registered.