Update rocket support to v0.5 (#406)
* update rocket support to v0.5 * added rocket upgrade to CHANGELOG.md * fix documentation code for rocket v0.5 --------- Co-authored-by: Chris Wong <lambda.fairy@gmail.com>
This commit is contained in:
parent
d3b871189f
commit
0de60b0c86
5 changed files with 12 additions and 11 deletions
|
@ -10,6 +10,8 @@
|
||||||
[#396](https://github.com/lambda-fairy/maud/pull/396)
|
[#396](https://github.com/lambda-fairy/maud/pull/396)
|
||||||
- Support `axum` v0.7 through `axum-core` v0.4 and `http` v1
|
- Support `axum` v0.7 through `axum-core` v0.4 and `http` v1
|
||||||
[#401](https://github.com/lambda-fairy/maud/pull/401)
|
[#401](https://github.com/lambda-fairy/maud/pull/401)
|
||||||
|
- Support `rocket` v0.5
|
||||||
|
[#406](https://github.com/lambda-fairy/maud/pull/406)
|
||||||
|
|
||||||
## [0.25.0] - 2023-04-16
|
## [0.25.0] - 2023-04-16
|
||||||
|
|
||||||
|
|
|
@ -60,22 +60,21 @@ maud = { version = "*", features = ["rocket"] }
|
||||||
This adds a `Responder` implementation for the `Markup` type, so you can return the result directly:
|
This adds a `Responder` implementation for the `Markup` type, so you can return the result directly:
|
||||||
|
|
||||||
```rust,no_run
|
```rust,no_run
|
||||||
#![feature(decl_macro)]
|
|
||||||
|
|
||||||
use maud::{html, Markup};
|
use maud::{html, Markup};
|
||||||
use rocket::{get, routes};
|
use rocket::{get, routes};
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
|
||||||
#[get("/<name>")]
|
#[get("/<name>")]
|
||||||
fn hello<'a>(name: Cow<'a, str>) -> Markup {
|
fn hello(name: &str) -> Markup {
|
||||||
html! {
|
html! {
|
||||||
h1 { "Hello, " (name) "!" }
|
h1 { "Hello, " (name) "!" }
|
||||||
p { "Nice to meet you!" }
|
p { "Nice to meet you!" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
#[rocket::launch]
|
||||||
rocket::ignite().mount("/", routes![hello]).launch();
|
fn launch() -> _ {
|
||||||
|
rocket::build().mount("/", routes![hello])
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ actix-web = { version = "4.0.0-rc.2", default-features = false, features = ["mac
|
||||||
ammonia = "3"
|
ammonia = "3"
|
||||||
maud = { path = "../maud", features = ["actix-web", "rocket", "tide", "axum"] }
|
maud = { path = "../maud", features = ["actix-web", "rocket", "tide", "axum"] }
|
||||||
pulldown-cmark = "0.8"
|
pulldown-cmark = "0.8"
|
||||||
rocket = "0.4"
|
rocket = "0.5"
|
||||||
rouille = "3"
|
rouille = "3"
|
||||||
tide = "0.16"
|
tide = "0.16"
|
||||||
tokio = { version = "1.9.0", features = ["rt", "macros", "rt-multi-thread"] }
|
tokio = { version = "1.9.0", features = ["rt", "macros", "rt-multi-thread"] }
|
||||||
|
|
|
@ -21,7 +21,7 @@ axum = ["axum-core", "http"]
|
||||||
[dependencies]
|
[dependencies]
|
||||||
maud_macros = { version = "0.25.0", path = "../maud_macros" }
|
maud_macros = { version = "0.25.0", path = "../maud_macros" }
|
||||||
itoa = "1"
|
itoa = "1"
|
||||||
rocket = { version = ">= 0.3, < 0.5", optional = true }
|
rocket = { version = "0.5", optional = true }
|
||||||
futures-util = { version = "0.3.0", optional = true, default-features = false }
|
futures-util = { version = "0.3.0", optional = true, default-features = false }
|
||||||
actix-web-dep = { package = "actix-web", version = "4", optional = true, default-features = false }
|
actix-web-dep = { package = "actix-web", version = "4", optional = true, default-features = false }
|
||||||
tide = { version = "0.16.0", optional = true, default-features = false }
|
tide = { version = "0.16.0", optional = true, default-features = false }
|
||||||
|
|
|
@ -284,17 +284,17 @@ mod rocket_support {
|
||||||
use crate::PreEscaped;
|
use crate::PreEscaped;
|
||||||
use alloc::string::String;
|
use alloc::string::String;
|
||||||
use rocket::{
|
use rocket::{
|
||||||
http::{ContentType, Status},
|
http::ContentType,
|
||||||
request::Request,
|
request::Request,
|
||||||
response::{Responder, Response},
|
response::{Responder, Response},
|
||||||
};
|
};
|
||||||
use std::io::Cursor;
|
use std::io::Cursor;
|
||||||
|
|
||||||
impl Responder<'static> for PreEscaped<String> {
|
impl<'r> Responder<'r, 'static> for PreEscaped<String> {
|
||||||
fn respond_to(self, _: &Request) -> Result<Response<'static>, Status> {
|
fn respond_to(self, _: &Request) -> rocket::response::Result<'static> {
|
||||||
Response::build()
|
Response::build()
|
||||||
.header(ContentType::HTML)
|
.header(ContentType::HTML)
|
||||||
.sized_body(Cursor::new(self.0))
|
.sized_body(self.0.len(), Cursor::new(self.0))
|
||||||
.ok()
|
.ok()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue