lambda-fairy / maud

:pencil: Compile-time HTML templates for Rust
https://maud.lambda.xyz
Apache License 2.0
1.98k stars 132 forks source link

Maud will need updating for Axum 7.0+ #414

Closed SamuelKurtzer closed 5 months ago

SamuelKurtzer commented 5 months ago

went to give maud a shot today and it looks like axum is unhappy with it for now.

use axum::{
    routing::{get, post},
    http::StatusCode,
    Json, Router,
};
use serde::{Deserialize, Serialize};
use maud::{html, Markup};

async fn hello_world() -> Markup {
    html! {
        h1 { "Hello, World!" }
    }
}

#[tokio::main]
async fn main() {
    // build our application with a route
    let app = Router::new()
        .route("/", get(hello_world));
    // run our app with hyper
    let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await.unwrap();
    axum::serve(listener, app).await.unwrap();
}
error[E0277]: the trait bound fn() -> impl Future<Output = PreEscaped<std::string::String>> {hello_world}: Handler<_, _> is not satisfied --> src/main.rs:14:25 14 .route("/", get(hello_world)); --- ^^^^^^^^^^^ the trait Handler<_, _> is not implemented for fn item fn() -> impl Future<Output = PreEscaped<std::string::String>> {hello_world}
required by a bound introduced by this call
= help: the following other types implement trait `Handler<T, S>`:
          <Layered<L, H, T, S> as Handler<T, S>>
          <MethodRouter<S> as Handler<(), S>>

Reverting to axum 0.6.2 fixed things, so maybe an update to the website to state version compatibility would be nice. I have no idea how to go about implementing the handler trait for Markup.

kcable194 commented 5 months ago

Release 0.26.0 seems to have fixed this issues (I was running into the same thing)