Quarkus already does 1 and 2 for you.
For 3, you only need to implement a custom NotFoundExceptionMapper
@Provider
public class NotFoundExceptionMapper implements ExceptionMapper<NotFoundException> {
@Override
@Produces(MediaType.TEXT_HTML)
public Response toResponse(NotFoundException exception) {
InputStream resource = ClassLoader.getSystemResourceAsStream("META-INF/resources/index.html");
return null == resource
? Response.status(NOT_FOUND).build()
: Response.ok().entity(resource).build();
}
}
Quarkus will use by order:
- File
xyz
, if exists in src/main/resources/META-INF/resources/
- Resource @Path("/xyz")
- Custom
NotFoundExceptionMapper