Skip to content

Get Route/Path name from function to be used for logging #2576

Answered by robjtede
roshanjrajan asked this question in Q&A
Discussion options

You must be logged in to vote
#[get("/api/endpoint1")] 
async fn api_request(req: HttpRequest) -> Result<String> {
    let path = req.path();
    ...
}

For logging, there's a built in Logger middleware (search docs).

Replies: 4 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by roshanjrajan
Comment options

You must be logged in to vote
1 reply
@robjtede
Comment options

Comment options

You must be logged in to vote
1 reply
@robjtede
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants