feat(core): add any() route registration, warn on undocumented OpenAPI routes, log unhandled 500s
Publish Maven packages / publish (push) Failing after 3m35s

FlashRegistrar#any() registers a handler under every HTTP method for
verb-indifferent handlers (e.g. a reverse proxy). OpenApiExtension now warns
when a class-based handler has no @ApiOperation instead of silently omitting
it from the spec. AbstractRouter's default production exception handler now
logs unhandled exceptions server-side instead of only returning a JSON 500.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Zakaria El Orche
2026-08-31 11:56:51 +00:00
co-authored by Claude Sonnet 5
parent 3d743b34ce
commit 74169e40f4
3 changed files with 16 additions and 1 deletions
@@ -51,6 +51,12 @@ public abstract class FlashRegistrar<SELF extends FlashRegistrar<SELF>> {
public final SELF purge (String path, SimpleHandler.FunctionalHandler h, Middleware... mw) { return route(HttpMethod.PURGE, path, h, mw); }
public final SELF query (String path, SimpleHandler.FunctionalHandler h, Middleware... mw) { return route(HttpMethod.QUERY, path, h, mw); }
/** Registers {@code h} under every {@link HttpMethod}: for handlers indifferent to verb (e.g. a proxy). */
public final SELF any(String path, SimpleHandler.FunctionalHandler h, Middleware... mw) {
for (HttpMethod m : HttpMethod.values()) route(m, path, h, mw);
return (SELF) this;
}
public final SELF getWith (String path, SimpleHandler.FunctionalHandler h, MiddlewareNode... mw) { return route(HttpMethod.GET, path, h, mw); }
public final SELF postWith (String path, SimpleHandler.FunctionalHandler h, MiddlewareNode... mw) { return route(HttpMethod.POST, path, h, mw); }
public final SELF putWith (String path, SimpleHandler.FunctionalHandler h, MiddlewareNode... mw) { return route(HttpMethod.PUT, path, h, mw); }
@@ -7,6 +7,7 @@ import dev.relism.flash.Flash;
import dev.relism.flash.http.ContentType;
import dev.relism.flash.http.HttpMethod;
import dev.relism.flash.template.ErrorPages;
import lombok.extern.slf4j.Slf4j;
import java.nio.charset.StandardCharsets;
@@ -29,6 +30,7 @@ import java.nio.charset.StandardCharsets;
* <p><b>Registration</b>: use {@link FlashApp} — the single
* public registration API. {@link #doRegister} is an infrastructure method.
*/
@Slf4j
public abstract class AbstractRouter {
/** Eagerly validates and compiles this route graph before traffic is accepted. */
@@ -59,6 +61,7 @@ public abstract class AbstractRouter {
return ErrorPages.renderException(req, ex);
}
: (ex, req, res) -> {
log.error("Unhandled exception in {} {}", req.method(), req.path(), ex);
res.status(500);
res.type(ContentType.JSON);
return JSON_500;