Update to support axum 0.2 (#303)
* Update to support axum 0.2 * Update changelog
This commit is contained in:
parent
c4cd049da8
commit
4374979a4f
5 changed files with 13 additions and 7 deletions
|
@ -2,6 +2,9 @@
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
- Update to support axum 0.2
|
||||||
|
[#303](https://github.com/lambda-fairy/maud/pull/303)
|
||||||
|
|
||||||
## [0.22.3] - 2021-09-27
|
## [0.22.3] - 2021-09-27
|
||||||
|
|
||||||
- Support `no_std` + `alloc`.
|
- Support `no_std` + `alloc`.
|
||||||
|
|
|
@ -194,7 +194,7 @@ This then allows you to use it directly as a response!
|
||||||
|
|
||||||
```rust,no_run
|
```rust,no_run
|
||||||
use maud::{html, Markup};
|
use maud::{html, Markup};
|
||||||
use axum::prelude::*;
|
use axum::{Router, handler::get};
|
||||||
|
|
||||||
async fn hello_world() -> Markup {
|
async fn hello_world() -> Markup {
|
||||||
html! {
|
html! {
|
||||||
|
@ -205,7 +205,7 @@ async fn hello_world() -> Markup {
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
// build our application with a single route
|
// build our application with a single route
|
||||||
let app = route("/", get(hello_world));
|
let app = Router::new().route("/", get(hello_world));
|
||||||
|
|
||||||
// run it with hyper on localhost:3000
|
// run it with hyper on localhost:3000
|
||||||
axum::Server::bind(&"0.0.0.0:3000".parse().unwrap())
|
axum::Server::bind(&"0.0.0.0:3000".parse().unwrap())
|
||||||
|
|
|
@ -14,7 +14,7 @@ rocket = "0.4"
|
||||||
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"] }
|
||||||
axum = "0.1.3"
|
axum = "0.2"
|
||||||
|
|
||||||
[dependencies.async-std]
|
[dependencies.async-std]
|
||||||
version = "1.9.0"
|
version = "1.9.0"
|
||||||
|
|
|
@ -25,7 +25,7 @@ rocket = { version = ">= 0.3, < 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 = ">= 2, < 4", optional = true, default-features = false }
|
actix-web-dep = { package = "actix-web", version = ">= 2, < 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 }
|
||||||
axum = { version = "0.1.3", optional = true }
|
axum = { version = "0.2", optional = true }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
trybuild = { version = "1.0.33", features = ["diff"] }
|
trybuild = { version = "1.0.33", features = ["diff"] }
|
||||||
|
|
|
@ -268,6 +268,9 @@ mod axum_support {
|
||||||
};
|
};
|
||||||
|
|
||||||
impl IntoResponse for PreEscaped<String> {
|
impl IntoResponse for PreEscaped<String> {
|
||||||
|
type Body = Body;
|
||||||
|
type BodyError = <Self::Body as axum::body::HttpBody>::Error;
|
||||||
|
|
||||||
fn into_response(self) -> Response<Body> {
|
fn into_response(self) -> Response<Body> {
|
||||||
let mut res = Response::new(Body::from(self.0));
|
let mut res = Response::new(Body::from(self.0));
|
||||||
*res.status_mut() = StatusCode::OK;
|
*res.status_mut() = StatusCode::OK;
|
||||||
|
|
Loading…
Add table
Reference in a new issue