Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Iron support #289

Merged
merged 2 commits into from
Nov 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
[#306](https://github.com/lambda-fairy/maud/pull/306)
- Update to Rust 2021
[#309](https://github.com/lambda-fairy/maud/pull/309)
- Remove Iron support
[#289](https://github.com/lambda-fairy/maud/pull/289)

## [0.22.3] - 2021-09-27

Expand Down
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 @@ -19,7 +19,6 @@ actix-web = ["actix-web-dep", "futures-util"]

[dependencies]
maud_macros = { version = "0.22.3", 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 @@ -208,35 +208,6 @@ impl<T: AsRef<str> + Into<String>> From<PreEscaped<T>> for String {
/// ```
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