Skip to content

Commit

Permalink
lock middleware behind a feature
Browse files Browse the repository at this point in the history
  • Loading branch information
mateocabanal committed Aug 12, 2023
1 parent 6c888c7 commit 1fc163f
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tinyhttp-internal/src/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ fn parse_request<P: Read + Write>(conn: &mut P, mut config: Config) {
// Therefore, request should always be Ok
let mut request = unsafe { request.unwrap_unchecked() };

#[cfg(feature = "middleware")]
if let Some(req_middleware) = config.get_request_middleware() {
req_middleware.lock().unwrap()(&mut request);
};
Expand Down Expand Up @@ -371,6 +372,7 @@ fn parse_request<P: Read + Write>(conn: &mut P, mut config: Config) {
);
}

#[cfg(feature = "middleware")]
if let Some(middleware) = config.get_response_middleware() {
middleware.lock().unwrap()(res_brw.deref_mut());
}
Expand Down

0 comments on commit 1fc163f

Please sign in to comment.