We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Display for FullPath
1 parent e3d3db4 commit 2d45197Copy full SHA for 2d45197
src/middleware/log_request.rs
@@ -166,13 +166,15 @@ struct FullPath<'a>(&'a dyn RequestExt);
166
167
impl<'a> Display for FullPath<'a> {
168
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
169
+ let request = self.0;
170
+
171
+ let original_path = request.extensions().find::<OriginalPath>();
172
// Unwrap shouldn't panic as no other code has access to the private struct to remove it
- write!(
- f,
- "{}",
173
- self.0.extensions().find::<OriginalPath>().unwrap().0
174
- )?;
175
- if let Some(q_string) = self.0.query_string() {
+ let path = original_path.map(|p| p.0.as_str()).unwrap();
+ write!(f, "{}", path)?;
176
177
+ if let Some(q_string) = request.query_string() {
178
write!(f, "?{}", q_string)?;
179
}
180
Ok(())
0 commit comments