Skip to content

Commit

Permalink
Fix error 500 on /
Browse files Browse the repository at this point in the history
  • Loading branch information
cerus committed Jun 11, 2022
1 parent 6184f4e commit d70833f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>dev.cerus</groupId>
<artifactId>mc-head-render</artifactId>
<version>1.0.0</version>
<version>1.0.1</version>

<properties>
<maven.compiler.source>17</maven.compiler.source>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@
public class RouteDocumenter {

public static void register(final WebServer webServer) {
webServer.getApp().get("/", context -> context.status(200).html(generateHtml()));
webServer.getApp().get("/", context -> context.status(200).html(generateHtml(webServer)));
webServer.getApp().error(404, ctx -> ctx.redirect("/"));
}

private static String generateHtml() {
private static String generateHtml(final WebServer webServer) {
final StringBuilder builder = new StringBuilder();
builder.append("<html><head><title>MCHR Api</title></head><body><h2>MCHR api endpoints</h2><ul>");

// V1
builder.append("<li><a>v1</a><ul>");
for (final Route route : RoutesV1.all()) {
for (final Route route : RoutesV1.all(webServer)) {
builder.append("<li><a href=\"").append(route.apiVersion()).append(route.path()).append("\">").append(route.type().name())
.append(" ").append(route.path()).append("</a>").append("<ul>");
builder.append("<li><a>").append(route.description()).append("</a></li>");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ private static void register(final Javalin app, final Route route) {
app.addHandler(route.type(), "/" + route.apiVersion() + route.path(), route);
}

public static List<Route> all() {
public static List<Route> all(final WebServer webServer) {
return List.of(
new InfoRouteV1(null),
new RenderRouteV1(null),
new SkinsRouteV1(null)
new InfoRouteV1(webServer),
new RenderRouteV1(webServer),
new SkinsRouteV1(webServer)
);
}

Expand Down

0 comments on commit d70833f

Please sign in to comment.