Skip to content

Commit

Permalink
Remove Iron support
Browse files Browse the repository at this point in the history
The Iron framework hasn't been updated in a long time. It still uses outdated versions of libraries like futures 0.1, hyper 0.12, url 1.7. We can speed up CI by removing it.
  • Loading branch information
lambda-fairy committed Sep 18, 2021
1 parent 2add073 commit a850d00
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 70 deletions.
39 changes: 1 addition & 38 deletions docs/content/web-frameworks.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# Web framework integration

Maud includes support for these web frameworks:
[Actix], [Iron], [Rocket], [Rouille], and [Tide].
[Actix], [Rocket], [Rouille], and [Tide].

[Actix]: https://actix.rs/
[Iron]: http://ironframework.io
[Rocket]: https://rocket.rs/
[Rouille]: https://github.com/tomaka/rouille
[Tide]: https://docs.rs/tide/
Expand Down Expand Up @@ -48,42 +47,6 @@ async fn main() -> io::Result<()> {
}
```

# Iron

Iron support is available with the "iron" feature:

```toml
# ...
[dependencies]
maud = { version = "*", features = ["iron"] }
# ...
```

With this feature enabled,
you can then build a `Response` from a `Markup` object directly.
Here's an example application using Iron and Maud:

```rust,no_run
use iron::prelude::*;
use iron::status;
use maud::html;
fn main() {
Iron::new(|r: &mut Request| {
let markup = html! {
h1 { "Hello, world!" }
p {
"You are viewing the page at " (r.url)
}
};
Ok(Response::with((status::Ok, markup)))
}).http("localhost:3000").unwrap();
}
```

`Markup` will set the content type of the response automatically,
so you don't need to add it yourself.

# Rocket

Rocket works in a similar way,
Expand Down
3 changes: 1 addition & 2 deletions doctest/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ edition = "2018"
[dependencies]
actix-web = "3"
ammonia = "3"
iron = "0.6"
maud = { path = "../maud", features = ["actix-web", "iron", "rocket", "tide", "axum"] }
maud = { path = "../maud", features = ["actix-web", "rocket", "tide", "axum"] }
pulldown-cmark = "0.8"
rocket = "0.4"
rouille = "3"
Expand Down
1 change: 0 additions & 1 deletion maud/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ actix-web = ["actix-web-dep", "futures-util"]
[dependencies]
maud_htmlescape = { version = "0.17.0", path = "../maud_htmlescape" }
maud_macros = { version = "0.22.2", path = "../maud_macros" }
iron = { version = ">= 0.5.1, < 0.7.0", optional = true }
rocket = { version = ">= 0.3, < 0.5", optional = true }
futures-util = { version = "0.3.0", optional = true, default-features = false }
actix-web-dep = { package = "actix-web", version = ">= 2, < 4", optional = true, default-features = false }
Expand Down
29 changes: 0 additions & 29 deletions maud/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,35 +171,6 @@ pub use maud_htmlescape::Escaper;
/// ```
pub const DOCTYPE: PreEscaped<&'static str> = PreEscaped("<!DOCTYPE html>");

#[cfg(feature = "iron")]
mod iron_support {
extern crate std;

use crate::PreEscaped;
use alloc::{boxed::Box, string::String};
use iron::{
headers::ContentType,
modifier::{Modifier, Set},
modifiers::Header,
response::{Response, WriteBody},
};
use std::io;

impl Modifier<Response> for PreEscaped<String> {
fn modify(self, response: &mut Response) {
response
.set_mut(Header(ContentType::html()))
.set_mut(Box::new(self) as Box<dyn WriteBody>);
}
}

impl WriteBody for PreEscaped<String> {
fn write_body(&mut self, body: &mut dyn io::Write) -> io::Result<()> {
self.0.write_body(body)
}
}
}

#[cfg(feature = "rocket")]
mod rocket_support {
extern crate std;
Expand Down

0 comments on commit a850d00

Please sign in to comment.