LemmyNet / activitypub-federation-rust

High-level Rust library for the Activitypub protocol
GNU Affero General Public License v3.0
409 stars 46 forks source link

Signing broken when using axum nested routers #73

Open ghost opened 1 year ago

pbzweihander commented 1 year ago

little bit more information:

If you run an axum server with following code:

use axum::{body::Body, http::Request, routing, Router};

async fn get(req: Request<Body>) {
    println!("{}", req.uri());
}

#[tokio::main]
async fn main() {
    let api = Router::new().route("/health", routing::get(get));
    let router = Router::new().nest("/api", api);

    axum::Server::bind(&"0.0.0.0:3030".parse().unwrap())
        .serve(router.into_make_service())
        .await
        .unwrap();
}

and request to localhost:3030/api/health?foo=bar, output is like:

/health?foo=bar

When we use nested router, axum's req.uri only shows matched path of the nested router.

pbzweihander commented 1 year ago

We can use MatchedPath to retrieve full path, but we have to somehow concatenate the query string.