mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-12-21 19:34:42 +01:00
Move the remaining HttpUtils function over to Router
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package emu.grasscutter.server.http;
|
||||
|
||||
import io.javalin.Javalin;
|
||||
import io.javalin.http.Handler;
|
||||
|
||||
/**
|
||||
* Defines routes for an {@link Javalin} instance.
|
||||
@@ -12,4 +13,21 @@ public interface Router {
|
||||
* @param javalin A Javalin instance.
|
||||
*/
|
||||
void applyRoutes(Javalin javalin);
|
||||
|
||||
/**
|
||||
* Applies this handler to all endpoint types
|
||||
* @param javalin A Javalin instance.
|
||||
* @param path
|
||||
* @param ctx
|
||||
* @return The Javalin instance.
|
||||
*/
|
||||
public default Javalin allRoutes(Javalin javalin, String path, Handler ctx) {
|
||||
javalin.get(path, ctx);
|
||||
javalin.post(path, ctx);
|
||||
javalin.put(path, ctx);
|
||||
javalin.patch(path, ctx);
|
||||
javalin.delete(path, ctx);
|
||||
|
||||
return javalin;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user