Skip to content

Commit a1f1d76

Browse files
authored
feat: Support URL wildcards on extraRoutes (#96)
* feat: Replace per-route extras wiring with ExtrasRouter Wire the single ExtrasRouter at "/" instead of creating one HttpContext per extra route. Delete ExtraRouteAdapter and NotFoundHandler, whose logic now lives in ExtrasRouter. Guard against extras when basePath is "/".
1 parent 2884d2a commit a1f1d76

14 files changed

Lines changed: 1780 additions & 141 deletions

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -905,6 +905,25 @@ Built-in helpers:
905905
opened and closed per request, and the handler owns its lifecycle). Throws
906906
`IllegalArgumentException` at construction if the resource or file is missing.
907907

908+
### Wildcards in extra routes
909+
910+
Extra routes accept two wildcard tokens (these are *not* part of OpenAPI;
911+
they apply only to extras, which are outside the spec):
912+
913+
- `*` — matches exactly one path segment (no `/`).
914+
- `**` — matches zero or more characters, may cross `/` boundaries.
915+
916+
Both must appear as whole segments (`/files/*`, `/files/**`,
917+
`/schemas/**/openapi.yaml`). Mixed-segment patterns like `prefix-*.json`
918+
are rejected at boot.
919+
920+
The matched portion is not exposed to the handler. If you map a wildcard
921+
extra to a filesystem location, canonicalise via `Path.toRealPath()` and
922+
assert `resolved.startsWith(baseReal)` to prevent escape — the router
923+
blocks `.`, `..`, encoded `%2e`/`%2f`/`%5c`/`%00`, control characters and
924+
malformed encoding with a 400, but cannot police what the handler does
925+
with the matched path.
926+
908927
### Health endpoint
909928

910929
`Handlers.healthHandler(probe)` mounts a readiness endpoint that aggregates per-dependency

0 commit comments

Comments
 (0)