Skip to content

Commit d0ca19d

Browse files
authored
Clarify directory gateway handler (#1343)
2 parents f458784 + 3b563ca commit d0ca19d

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

payjoin-directory/src/lib.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ impl<D: Db> Service<D> {
227227
Ok(response)
228228
}
229229

230+
/// Handle an encapsulated OHTTP request and return an encapsulated response
230231
async fn handle_ohttp_gateway<B>(
231232
&self,
232233
body: B,
@@ -235,12 +236,12 @@ impl<D: Db> Service<D> {
235236
B: Body<Data = Bytes> + Send + 'static,
236237
B::Error: Into<BoxError>,
237238
{
239+
// Decapsulate OHTTP request
238240
let ohttp_body = body
239241
.collect()
240242
.await
241243
.map_err(|e| HandlerError::BadRequest(anyhow::anyhow!(e.into())))?
242244
.to_bytes();
243-
244245
let (bhttp_req, res_ctx) = self
245246
.ohttp
246247
.decapsulate(&ohttp_body)
@@ -261,8 +262,10 @@ impl<D: Db> Service<D> {
261262
}
262263
let request = http_req.body(full(body))?;
263264

264-
let response = self.handle_v2(request).await?;
265+
// Handle decapsulated request
266+
let response = self.handle_decapsulated_request(request).await?;
265267

268+
// Encapsulate OHTTP response
266269
let (parts, body) = response.into_parts();
267270
let mut bhttp_res = bhttp::Message::response(
268271
bhttp::StatusCode::try_from(parts.status.as_u16())
@@ -289,7 +292,7 @@ impl<D: Db> Service<D> {
289292
Ok(Response::new(full(ohttp_res)))
290293
}
291294

292-
async fn handle_v2(
295+
async fn handle_decapsulated_request(
293296
&self,
294297
req: Request<BoxBody<Bytes, hyper::Error>>,
295298
) -> Result<Response<BoxBody<Bytes, hyper::Error>>, HandlerError> {

0 commit comments

Comments
 (0)