summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2025-06-27 18:08:42 -0600
committermo khan <mo@mokhan.ca>2025-06-27 18:08:42 -0600
commit12550869b5f9c50a6ce6c9ab54eee456b32057da (patch)
treec4c3c118062c2ccc31fe50c22a4b374b769f2b94 /src
parenteb3914a616cda9e2a777a47be7ad4387319df94e (diff)
chore: add a logging interceptor to log request
Diffstat (limited to 'src')
-rw-r--r--src/authorization/server.rs16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/authorization/server.rs b/src/authorization/server.rs
index 2605bd54..de7df580 100644
--- a/src/authorization/server.rs
+++ b/src/authorization/server.rs
@@ -9,12 +9,15 @@ pub struct Server {
impl Server {
pub fn new() -> Result<Server, Box<dyn std::error::Error>> {
+ let (_health_reporter, health_service) = tonic_health::server::health_reporter();
+ let authorization_service = AuthorizationServer::with_interceptor(
+ CheckService::new(Arc::new(CedarAuthorizer::default())),
+ logging_interceptor,
+ );
+
Ok(Self::new_with(|mut builder| {
- let (_health_reporter, health_service) = tonic_health::server::health_reporter();
- let authorizer = Arc::new(CedarAuthorizer::default());
- let check_service = CheckService::new(authorizer);
builder
- .add_service(AuthorizationServer::new(check_service))
+ .add_service(authorization_service)
.add_service(health_service)
}))
}
@@ -37,3 +40,8 @@ impl Default for Server {
Self::new().unwrap()
}
}
+
+fn logging_interceptor<T>(request: tonic::Request<T>) -> Result<tonic::Request<T>, tonic::Status> {
+ log::info!("gRPC request received");
+ Ok(request)
+}