You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, I am creating a rate limiter endpoint which is tracking based on request IP and URI. This works well except for paths with patterns (i.e. /object/:id). Instead of using req.uri() I'd like to use something similar to PathPattern, is this possible in middleware?
impl<E:Endpoint>EndpointforRateLimitEndpoint<E>{typeOutput = Response;asyncfncall(&self,req:Request) -> Result<Self::Output>{let key = format!("{}:{}",
RealIp::from_request_without_body(&req)
.await
.map(|addr| addr.0.map(|addr| addr.to_string()))?
.unwrap_or("localhost".to_string()),
req.uri()// want this to be "/object/:id" instead of "/object/1", "/object/2", etc);// ..}}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello, I am creating a rate limiter endpoint which is tracking based on request IP and URI. This works well except for paths with patterns (i.e.
/object/:id
). Instead of usingreq.uri()
I'd like to use something similar to PathPattern, is this possible in middleware?Beta Was this translation helpful? Give feedback.
All reactions