Skip to content

Commit e7c7ae1

Browse files
committed
fix: add midleware example
1 parent feea040 commit e7c7ae1

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

sentry/src/lib.rs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -106,20 +106,10 @@ impl<A: Adapter + 'static> Application<A> {
106106
return map_response_error(ResponseError::BadRequest("invalid auth".into()));
107107
}
108108
};
109-
109+
110110
let mut response = match (req.uri().path(), req.method()) {
111111
("/cfg", &Method::GET) => config(req, &self).await,
112-
("/channel", &Method::POST) => {
113-
// example with middleware
114-
// @TODO remove later
115-
let req = match chain(req, vec![config_middleware]).await {
116-
Ok(req) => req,
117-
Err(error) => {
118-
return map_response_error(error);
119-
}
120-
};
121-
create_channel(req, &self).await
122-
}
112+
("/channel", &Method::POST) => create_channel(req, &self).await,
123113
("/channel/list", &Method::GET) => Err(ResponseError::NotFound),
124114
// This is important becuase it prevents us from doing
125115
// expensive regex matching for routes without /channel
@@ -135,6 +125,15 @@ impl<A: Adapter + 'static> Application<A> {
135125
.map_or("".to_string(), |m| m.as_str().to_string())]);
136126
req.extensions_mut().insert(param);
137127

128+
// example with middleware
129+
// @TODO remove later
130+
let req = match chain(req, vec![config_middleware]).await {
131+
Ok(req) => req,
132+
Err(error) => {
133+
return map_response_error(error);
134+
}
135+
};
136+
138137
last_approved(req, &self).await
139138
} else {
140139
Err(ResponseError::NotFound)

0 commit comments

Comments
 (0)