mirror of https://github.com/rwf2/Rocket.git
parent
95c981de79
commit
39b1f2f8d0
|
@ -735,20 +735,15 @@ use rocket::request::FlashMessage;
|
||||||
|
|
||||||
#[get("/")]
|
#[get("/")]
|
||||||
fn bad(cookies: Cookies, flash: FlashMessage) {
|
fn bad(cookies: Cookies, flash: FlashMessage) {
|
||||||
|
// Oh no! `flash` holds a reference to `Cookies` too!
|
||||||
let msg = flash.msg();
|
let msg = flash.msg();
|
||||||
}
|
}
|
||||||
```
|
|
||||||
|
|
||||||
```rust
|
|
||||||
# #[macro_use] extern crate rocket;
|
|
||||||
# fn main() {}
|
|
||||||
|
|
||||||
# use rocket::http::Cookies;
|
|
||||||
# use rocket::request::FlashMessage;
|
|
||||||
|
|
||||||
#[get("/")]
|
#[get("/")]
|
||||||
fn good(cookies: Cookies, flash: FlashMessage) {
|
fn good(cookies: Cookies, flash: FlashMessage) {
|
||||||
std::mem::drop(cookies);
|
std::mem::drop(cookies);
|
||||||
|
|
||||||
|
// Now, `flash` holds an _exclusive_ reference to `Cookies`. Whew.
|
||||||
let msg = flash.msg();
|
let msg = flash.msg();
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
|
@ -331,6 +331,13 @@ fn get_logs(conn: LogsDbConn, id: usize) -> Logs {
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
! note The above examples uses [Diesel] with some fictional `Logs` type.
|
||||||
|
|
||||||
|
The example above contains the use of a `Logs` type that is application
|
||||||
|
specific and not built into Rocket. It also uses [Diesel]'s query-building
|
||||||
|
syntax. Rocket does not provide an ORM. It is up to you to decide how to model
|
||||||
|
your application's data.
|
||||||
|
|
||||||
If your application uses features of a database engine that are not available
|
If your application uses features of a database engine that are not available
|
||||||
by default, for example support for `chrono` or `uuid`, you may enable those
|
by default, for example support for `chrono` or `uuid`, you may enable those
|
||||||
features by adding them in `Cargo.toml` like so:
|
features by adding them in `Cargo.toml` like so:
|
||||||
|
|
|
@ -205,7 +205,7 @@ We do this by checking the `Response` object directly:
|
||||||
|
|
||||||
# use rocket::local::Client;
|
# use rocket::local::Client;
|
||||||
use rocket::http::{ContentType, Status};
|
use rocket::http::{ContentType, Status};
|
||||||
|
#
|
||||||
# let rocket = rocket::ignite().mount("/", routes![hello]);
|
# let rocket = rocket::ignite().mount("/", routes![hello]);
|
||||||
# let client = Client::new(rocket).expect("valid rocket instance");
|
# let client = Client::new(rocket).expect("valid rocket instance");
|
||||||
# let mut response = client.get("/").dispatch();
|
# let mut response = client.get("/").dispatch();
|
||||||
|
|
Loading…
Reference in New Issue