Skip to content
Snippets Groups Projects
Commit 7470b452 authored by Andreas Schärtl's avatar Andreas Schärtl
Browse files

uloapi: set up basic routing

parent a382a291
No related branches found
No related tags found
No related merge requests found
......@@ -3,7 +3,10 @@ package info.mathhub.uloapi;
import static spark.Spark.*;
public class Main {
private Main() {};
public static void main(String[] args) {
get("/hello", (req, res) -> "Hello World");
get("/", Routes.index);
get("/favicon.ico", Routes.createError(404));
}
}
package info.mathhub.uloapi;
import spark.*;
/**
* This class contains all routes of our application.
*/
public class Routes {
private Routes() {};
public static final Route index = (Request request, Response response) -> {
return "<h1>Index /</h1>";
};
public static Route createError(int status) {
return (Request request, Response response) -> {
response.status(status);
return String.format("Error %d", status);
};
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment