Document that pre_request_handler runs for WebSocket routes

This commit is contained in:
yhirose
2026-09-19 15:11:34 -04:00
parent 4cb363e3f2
commit 2e5480ad65
6 changed files with 22 additions and 0 deletions

View File

@@ -37,6 +37,8 @@ svr.set_pre_request_handler(
`matched_route` is the pattern **before** path parameters are expanded (e.g. `/admin/users/:id`). You compare against the route definition, not the actual request path, so IDs or names don't throw you off.
The pre-request handler also runs for routes registered with `svr.WebSocket()`. It is called before the `101 Switching Protocols` response, so returning `Handled` sends your HTTP response (such as a 403) and the connection is never upgraded.
## Return values
Same as pre-routing — return `HandlerResponse`.