Skip to content

Commit 709fde9

Browse files
committed
feat: Add AfterResponseHook interface
1 parent bbaace7 commit 709fde9

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.retailsvc.http;
2+
3+
/**
4+
* Callback invoked after an HTTP response has been written to the client. Runs on the same virtual
5+
* thread that handled the request, inside the library's request {@link ScopedValue} binding.
6+
*
7+
* <p>Hooks fire only when a {@link Request} was successfully constructed — i.e., routing and
8+
* parameter/body validation passed. Pre-request failures (404, 405, 400 validation) do not fire
9+
* hooks.
10+
*
11+
* <p>On the error path, {@link Response#body()} is always {@code null} because the body bytes have
12+
* already been sent. {@link Response#status()} and {@link Response#headers()} reflect what was
13+
* written to the wire.
14+
*
15+
* <p>Exceptions thrown by a hook are logged at DEBUG and swallowed; subsequent hooks still run.
16+
* Hooks compose in registration order.
17+
*/
18+
@FunctionalInterface
19+
public interface AfterResponseHook {
20+
21+
void after(Request request, Response response);
22+
}

0 commit comments

Comments
 (0)