Skip to content

Commit

Permalink
Update rocket support to v0.5 (#406)
Browse files Browse the repository at this point in the history
* update rocket support to v0.5

* added rocket upgrade to CHANGELOG.md

* fix documentation code for rocket v0.5

---------

Co-authored-by: Chris Wong <[email protected]>
  • Loading branch information
SenojLuap and lambda-fairy authored Dec 30, 2023
1 parent d3b8711 commit 0de60b0
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
[#396](https://github.com/lambda-fairy/maud/pull/396)
- Support `axum` v0.7 through `axum-core` v0.4 and `http` v1
[#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

Expand Down
9 changes: 4 additions & 5 deletions docs/content/web-frameworks.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,22 +60,21 @@ maud = { version = "*", features = ["rocket"] }
This adds a `Responder` implementation for the `Markup` type, so you can return the result directly:

```rust,no_run
#![feature(decl_macro)]
use maud::{html, Markup};
use rocket::{get, routes};
use std::borrow::Cow;
#[get("/<name>")]
fn hello<'a>(name: Cow<'a, str>) -> Markup {
fn hello(name: &str) -> Markup {
html! {
h1 { "Hello, " (name) "!" }
p { "Nice to meet you!" }
}
}
fn main() {
rocket::ignite().mount("/", routes![hello]).launch();
#[rocket::launch]
fn launch() -> _ {
rocket::build().mount("/", routes![hello])
}
```

Expand Down
2 changes: 1 addition & 1 deletion doctest/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ actix-web = { version = "4.0.0-rc.2", default-features = false, features = ["mac
ammonia = "3"
maud = { path = "../maud", features = ["actix-web", "rocket", "tide", "axum"] }
pulldown-cmark = "0.8"
rocket = "0.4"
rocket = "0.5"
rouille = "3"
tide = "0.16"
tokio = { version = "1.9.0", features = ["rt", "macros", "rt-multi-thread"] }
Expand Down
2 changes: 1 addition & 1 deletion maud/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ axum = ["axum-core", "http"]
[dependencies]
maud_macros = { version = "0.25.0", path = "../maud_macros" }
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 }
actix-web-dep = { package = "actix-web", version = "4", optional = true, default-features = false }
tide = { version = "0.16.0", optional = true, default-features = false }
Expand Down
8 changes: 4 additions & 4 deletions maud/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,17 +284,17 @@ mod rocket_support {
use crate::PreEscaped;
use alloc::string::String;
use rocket::{
http::{ContentType, Status},
http::ContentType,
request::Request,
response::{Responder, Response},
};
use std::io::Cursor;

impl Responder<'static> for PreEscaped<String> {
fn respond_to(self, _: &Request) -> Result<Response<'static>, Status> {
impl<'r> Responder<'r, 'static> for PreEscaped<String> {
fn respond_to(self, _: &Request) -> rocket::response::Result<'static> {
Response::build()
.header(ContentType::HTML)
.sized_body(Cursor::new(self.0))
.sized_body(self.0.len(), Cursor::new(self.0))
.ok()
}
}
Expand Down

0 comments on commit 0de60b0

Please sign in to comment.