Actix-web: Print Request Information

How do I write a rule that applies to all routes that prints out certain things?

Currently, I have about 20 different routes that do all of this:

async fn login(body: String) -> HttpResponse {
    println!("{}",format!("post -> /login").cyan());

What I want to do is define something that has the 3 printlns in it and have all the routes print that information in that structure.

Would I do this in a macro?

You should use a middleware for that.

1 Like

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.