mirror of https://github.com/rwf2/Rocket.git
7cc818cd85
This commit introduces the ability to dynamically select a TLS configuration based on the client's TLS hello via the new `Resolver` trait. In support of this, it also makes the following changes: * Added `Authority::set_port()`. * `UdsListener` is now `UnixListener`. * `Bindable` removed in favor of new `Bind`. * All built-in listeners now implement `Bind<&Rocket>`. * `Connection` requires `AsyncRead + AsyncWrite`. * The `Debug` impl for `Endpoint` displays the underlying address. * `Listener` must be `Sized`. * The TLS listener was moved to `tls::TlsListener`. * The preview `quic` listener no longer implements `Listener`. * Added `TlsConfig::server_config()`. * Added `race` future helpers. * Added `Rocket::launch_with()`, `Rocket::bind_launch()`. * Added a default `client.pem` to the TLS example. * Various unnecessary listener `Config` structures removed. In addition, the testbench was revamped to support more scenarios. This resulted in the following issues being found and fixed: * Fix an issue where the logger would ignore color requests. * Clarified docs for `mtls::Certificate` guard. * Improved error messages on listener misconfiguration. Resolves #2730. Resolves #2363. Closes #2748. Closes #2683. Closes #2577. |
||
---|---|---|
.. | ||
codegen | ||
lib | ||
README.md |
README.md
sync_db_pools
This crate provides traits, utilities, and a procedural macro for configuring
and accessing database connection pools in Rocket. This implementation is backed
by r2d2
and exposes connections through request guards.
Usage
First, enable the feature corresponding to your database type:
[dependencies.rocket_sync_db_pools]
version = "0.1.0"
features = ["diesel_sqlite_pool"]
A full list of supported databases and their associated feature names is
available in the crate docs. In whichever configuration source you choose,
configure a databases
dictionary with a key for each database, here
sqlite_logs
in a TOML source:
[default.databases]
sqlite_logs = { url = "/path/to/database.sqlite" }
In your application's source code:
#[macro_use] extern crate rocket;
use rocket_sync_db_pools::{database, diesel};
#[database("sqlite_logs")]
struct LogsDbConn(diesel::SqliteConnection);
#[get("/logs/<id>")]
async fn get_logs(conn: LogsDbConn, id: usize) -> Result<Logs> {
conn.run(|c| Logs::by_id(c, id)).await
}
#[launch]
fn rocket() -> _ {
rocket::build().attach(LogsDbConn::fairing())
}
See the crate docs for full details.