Actix-web service not triggering

I can't seem to figure out why the following code will not work:

use actix_web::{get, post, web, App, HttpResponse, HttpServer, Responder};

// Permenant Redirect Cookie
#[get("/some/url/308")]
async fn new_visitor() -> impl Responder {
    println!("New visitor!");
    HttpResponse::PermanentRedirect()
        .header(
            "location",
            format!(
                "/some/url/308={}",
                random_string::generate(16, "0123456789ABCDEF")
            ),
        )
        .finish()
}

#[get("/some/url/308={id}")]
async fn repeat_visitor(web::Path(id): web::Path<String>) -> impl Responder {
    println!("ID: {}", id);
    HttpResponse::NoContent()
}

#[post("/some/url/?{key}={value}")]
async fn new_prop(web::Path((key, value)): web::Path<(String, String)>) -> impl Responder {
    println!("{}: {}", key, value);
    HttpResponse::NoContent()
}

#[actix_web::main]
async fn main() -> std::io::Result<()> {
    const PORT: u16 = 8000;
    println!("🚀 Server running on port: {}", PORT);

    HttpServer::new(|| {
        App::new()
            .service(new_visitor)
            .service(repeat_visitor)
            .service(new_prop)
    })
    .bind(format!("127.0.0.1:{}", PORT))?
    .run()
    .await
}

The first two services seem to work perfectly, however, I get no response on new_prop. Any help would be greatly appreciated!

How are you testing it? Is the client sending a POST request?

Ah, I can't believe I didn't notice that. My apologies!

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.