mirror of https://github.com/rwf2/Rocket.git
parent
4618bd0a5e
commit
878a73b6f0
|
@ -735,20 +735,15 @@ use rocket::request::FlashMessage;
|
|||
|
||||
#[get("/")]
|
||||
fn bad(cookies: Cookies, flash: FlashMessage) {
|
||||
// Oh no! `flash` holds a reference to `Cookies` too!
|
||||
let msg = flash.msg();
|
||||
}
|
||||
```
|
||||
|
||||
```rust
|
||||
# #[macro_use] extern crate rocket;
|
||||
# fn main() {}
|
||||
|
||||
# use rocket::http::Cookies;
|
||||
# use rocket::request::FlashMessage;
|
||||
|
||||
#[get("/")]
|
||||
fn good(cookies: Cookies, flash: FlashMessage) {
|
||||
std::mem::drop(cookies);
|
||||
|
||||
// Now, `flash` holds an _exclusive_ reference to `Cookies`. Whew.
|
||||
let msg = flash.msg();
|
||||
}
|
||||
```
|
||||
|
|
|
@ -397,7 +397,7 @@ fairings. To attach the template fairing, simply call
|
|||
|
||||
fn main() {
|
||||
rocket::ignite()
|
||||
.mount("/", routes![ /* .. */])
|
||||
.mount("/", routes![/* .. */])
|
||||
.attach(Template::fairing());
|
||||
}
|
||||
```
|
||||
|
|
|
@ -328,6 +328,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
|
||||
by default, for example support for `chrono` or `uuid`, you may enable those
|
||||
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::http::{ContentType, Status};
|
||||
|
||||
#
|
||||
# let rocket = rocket::ignite().mount("/", routes![hello]);
|
||||
# let client = Client::new(rocket).expect("valid rocket instance");
|
||||
# let mut response = client.get("/").dispatch();
|
||||
|
|
Loading…
Reference in New Issue