-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Phillip Kruger <[email protected]>
- Loading branch information
1 parent
a5ffb89
commit 2e37b5f
Showing
11 changed files
with
387 additions
and
289 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
...ns/undertow/runtime/src/main/java/io/quarkus/undertow/runtime/QuarkusNotFoundServlet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package io.quarkus.undertow.runtime; | ||
|
||
import java.io.IOException; | ||
import java.nio.charset.StandardCharsets; | ||
|
||
import jakarta.enterprise.inject.spi.CDI; | ||
import jakarta.servlet.ServletException; | ||
import jakarta.servlet.http.HttpServlet; | ||
import jakarta.servlet.http.HttpServletRequest; | ||
import jakarta.servlet.http.HttpServletResponse; | ||
|
||
import io.quarkus.vertx.http.runtime.devmode.ResourceNotFoundData; | ||
import io.vertx.core.json.Json; | ||
|
||
public class QuarkusNotFoundServlet extends HttpServlet { | ||
|
||
@Override | ||
protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { | ||
ResourceNotFoundData resourceNotFoundData = CDI.current().select(ResourceNotFoundData.class).get(); | ||
String accept = req.getHeader("Accept"); | ||
if (accept != null && accept.contains("application/json")) { | ||
resp.setContentType("application/json"); | ||
resp.setCharacterEncoding(StandardCharsets.UTF_8.name()); | ||
resp.getWriter().write(Json.encodePrettily(resourceNotFoundData.getJsonContent())); | ||
} else { | ||
//We default to HTML representation | ||
resp.setContentType("text/html"); | ||
resp.setCharacterEncoding(StandardCharsets.UTF_8.name()); | ||
resp.getWriter().write(resourceNotFoundData.getHTMLContent()); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.