-
public class ApiBuilder
Static methods for route declarations in Javalin
-
-
Field Summary
Fields Modifier and Type Field Description private final static ThreadLocal<Javalin>
staticJavalin
-
Method Summary
Modifier and Type Method Description static void
setStaticJavalin(@NotNull() Javalin javalin)
static void
clearStaticJavalin()
static void
path(@NotNull() String path, @NotNull() EndpointGroup endpointGroup)
Prefixes all handlers defined in its scope with the specified path. static String
prefixPath(@NotNull() String path)
static Javalin
staticInstance()
static void
get(@NotNull() String path, @NotNull() Handler handler)
Adds a GET request handler for the specified path to the Javalin instance. static void
get(@NotNull() String path, @NotNull() Handler handler, @NotNull() Array<RouteRole> roles)
Adds a GET request handler with the given roles for the specified path to the instance. static void
get(@NotNull() Handler handler)
Adds a GET request handler for the current path to the Javalin instance. static void
get(@NotNull() Handler handler, @NotNull() Array<RouteRole> roles)
Adds a GET request handler with the given roles for the current path to the instance. static void
post(@NotNull() String path, @NotNull() Handler handler)
Adds a POST request handler for the specified path to the Javalin instance. static void
post(@NotNull() String path, @NotNull() Handler handler, @NotNull() Array<RouteRole> roles)
Adds a POST request handler with the given roles for the specified path to the instance. static void
post(@NotNull() Handler handler)
Adds a POST request handler for the current path to the Javalin instance. static void
post(@NotNull() Handler handler, @NotNull() Array<RouteRole> roles)
Adds a POST request handler with the given roles for the current path to the instance. static void
put(@NotNull() String path, @NotNull() Handler handler)
Adds a PUT request handler for the specified path to the Javalin instance. static void
put(@NotNull() String path, @NotNull() Handler handler, @NotNull() Array<RouteRole> roles)
Adds a PUT request handler with the given roles for the specified path to the instance. static void
put(@NotNull() Handler handler)
Adds a PUT request handler for the current path to the Javalin instance. static void
put(@NotNull() Handler handler, @NotNull() Array<RouteRole> roles)
Adds a PUT request handler with the given roles for the current path to the instance. static void
patch(@NotNull() String path, @NotNull() Handler handler)
Adds a PATCH request handler for the specified path to the Javalin instance. static void
patch(@NotNull() String path, @NotNull() Handler handler, @NotNull() Array<RouteRole> roles)
Adds a PATCH request handler with the given roles for the specified path to the instance. static void
patch(@NotNull() Handler handler)
Adds a PATCH request handler for the current path to the Javalin instance. static void
patch(@NotNull() Handler handler, @NotNull() Array<RouteRole> roles)
Adds a PATCH request handler with the given roles for the current path to the instance. static void
delete(@NotNull() String path, @NotNull() Handler handler)
Adds a DELETE request handler for the specified path to the Javalin instance. static void
delete(@NotNull() String path, @NotNull() Handler handler, @NotNull() Array<RouteRole> roles)
Adds a DELETE request handler with the given roles for the specified path to the instance. static void
delete(@NotNull() Handler handler)
Adds a DELETE request handler for the current path to the Javalin instance. static void
delete(@NotNull() Handler handler, @NotNull() Array<RouteRole> roles)
Adds a DELETE request handler with the given roles for the current path to the instance. static void
head(@NotNull() String path, @NotNull() Handler handler)
Adds a HEAD request handler for the specified path to the Javalin instance. static void
head(@NotNull() String path, @NotNull() Handler handler, @NotNull() Array<RouteRole> roles)
Adds a HEAD request handler with the given roles for the specified path to the instance. static void
head(@NotNull() Handler handler)
Adds a HEAD request handler for the current path to the Javalin instance. static void
head(@NotNull() Handler handler, @NotNull() Array<RouteRole> roles)
Adds a HEAD request handler with the given roles for the current path to the instance. static void
before(@NotNull() String path, @NotNull() Handler handler)
Adds a BEFORE request handler for the specified path to the Javalin instance. static void
before(@NotNull() Handler handler)
Adds a BEFORE request handler for the current path to the Javalin instance. static void
after(@NotNull() String path, @NotNull() Handler handler)
Adds an AFTER request handler for the specified path to the Javalin instance. static void
after(@NotNull() Handler handler)
Adds a AFTER request handler for the current path to the Javalin instance. static void
ws(@NotNull() String path, @NotNull() Consumer<WsConfig> ws)
Adds a WebSocket handler on the specified path. static void
ws(@NotNull() String path, @NotNull() Consumer<WsConfig> ws, @NotNull() Array<RouteRole> roles)
Adds a WebSocket handler with the given roles for the specified path. static void
ws(@NotNull() Consumer<WsConfig> ws)
Adds a WebSocket handler on the current path. static void
ws(@NotNull() Consumer<WsConfig> ws, @NotNull() Array<RouteRole> roles)
Adds a WebSocket handler with the given roles for the current path. Javalin
wsBefore(@NotNull() String path, @NotNull() Consumer<WsConfig> wsConfig)
Adds a WebSocket before handler for the specified path to the Javalin instance. Javalin
wsBefore(@NotNull() Consumer<WsConfig> wsConfig)
Adds a WebSocket before handler for the current path to the Javalin instance. Javalin
wsAfter(@NotNull() String path, @NotNull() Consumer<WsConfig> wsConfig)
Adds a WebSocket after handler for the specified path to the Javalin instance. Javalin
wsAfter(@NotNull() Consumer<WsConfig> wsConfig)
Adds a WebSocket after handler for the current path to the Javalin instance. static void
sse(@NotNull() String path, @NotNull() Consumer<SseClient> client)
static void
sse(@NotNull() String path, @NotNull() Consumer<SseClient> client, @NotNull() Array<RouteRole> roles)
static void
sse(@NotNull() Consumer<SseClient> client)
static void
sse(@NotNull() Consumer<SseClient> client, @NotNull() Array<RouteRole> roles)
static void
crud(@NotNull() CrudHandler crudHandler)
Adds a CrudHandler handler to the current path to the Javalin instance. static void
crud(@NotNull() CrudHandler crudHandler, @NotNull() Array<RouteRole> roles)
Adds a CrudHandler handler to the current path with the given roles to the Javalin instance. static void
crud(@NotNull() String path, @NotNull() CrudHandler crudHandler)
Adds a CrudHandler handler to the specified path to the Javalin instance. static void
crud(@NotNull() String path, @NotNull() CrudHandler crudHandler, @NotNull() Array<RouteRole> roles)
Adds a CrudHandler handler to the specified path with the given roles to the Javalin instance. -
-
Method Detail
-
setStaticJavalin
static void setStaticJavalin(@NotNull() Javalin javalin)
-
clearStaticJavalin
static void clearStaticJavalin()
-
path
static void path(@NotNull() String path, @NotNull() EndpointGroup endpointGroup)
Prefixes all handlers defined in its scope with the specified path.All paths are normalized, so you can call bothpath("/path") or path("path") depending on your preferenceThe method can only be called inside a routes.
-
prefixPath
static String prefixPath(@NotNull() String path)
-
staticInstance
static Javalin staticInstance()
-
get
static void get(@NotNull() String path, @NotNull() Handler handler, @NotNull() Array<RouteRole> roles)
Adds a GET request handler with the given roles for the specified path to the instance.The method can only be called inside a routes.
-
get
static void get(@NotNull() Handler handler, @NotNull() Array<RouteRole> roles)
Adds a GET request handler with the given roles for the current path to the instance.The method can only be called inside a routes.
-
post
static void post(@NotNull() String path, @NotNull() Handler handler, @NotNull() Array<RouteRole> roles)
Adds a POST request handler with the given roles for the specified path to the instance.The method can only be called inside a routes.
-
post
static void post(@NotNull() Handler handler, @NotNull() Array<RouteRole> roles)
Adds a POST request handler with the given roles for the current path to the instance.The method can only be called inside a routes.
-
put
static void put(@NotNull() String path, @NotNull() Handler handler, @NotNull() Array<RouteRole> roles)
Adds a PUT request handler with the given roles for the specified path to the instance.The method can only be called inside a routes.
-
put
static void put(@NotNull() Handler handler, @NotNull() Array<RouteRole> roles)
Adds a PUT request handler with the given roles for the current path to the instance.The method can only be called inside a routes.
-
patch
static void patch(@NotNull() String path, @NotNull() Handler handler, @NotNull() Array<RouteRole> roles)
Adds a PATCH request handler with the given roles for the specified path to the instance.The method can only be called inside a routes.
-
patch
static void patch(@NotNull() Handler handler, @NotNull() Array<RouteRole> roles)
Adds a PATCH request handler with the given roles for the current path to the instance.The method can only be called inside a routes.
-
delete
static void delete(@NotNull() String path, @NotNull() Handler handler, @NotNull() Array<RouteRole> roles)
Adds a DELETE request handler with the given roles for the specified path to the instance.The method can only be called inside a routes.
-
delete
static void delete(@NotNull() Handler handler, @NotNull() Array<RouteRole> roles)
Adds a DELETE request handler with the given roles for the current path to the instance.The method can only be called inside a routes.
-
head
static void head(@NotNull() String path, @NotNull() Handler handler, @NotNull() Array<RouteRole> roles)
Adds a HEAD request handler with the given roles for the specified path to the instance.The method can only be called inside a routes.
-
head
static void head(@NotNull() Handler handler, @NotNull() Array<RouteRole> roles)
Adds a HEAD request handler with the given roles for the current path to the instance.The method can only be called inside a routes.
-
ws
static void ws(@NotNull() String path, @NotNull() Consumer<WsConfig> ws)
Adds a WebSocket handler on the specified path.The method can only be called inside a routes.
-
ws
static void ws(@NotNull() String path, @NotNull() Consumer<WsConfig> ws, @NotNull() Array<RouteRole> roles)
Adds a WebSocket handler with the given roles for the specified path.The method can only be called inside a routes.
-
ws
static void ws(@NotNull() Consumer<WsConfig> ws)
Adds a WebSocket handler on the current path.The method can only be called inside a routes.
-
ws
static void ws(@NotNull() Consumer<WsConfig> ws, @NotNull() Array<RouteRole> roles)
Adds a WebSocket handler with the given roles for the current path.The method can only be called inside a routes.
-
sse
static void sse(@NotNull() String path, @NotNull() Consumer<SseClient> client, @NotNull() Array<RouteRole> roles)
-
crud
static void crud(@NotNull() CrudHandler crudHandler)
-
crud
static void crud(@NotNull() CrudHandler crudHandler, @NotNull() Array<RouteRole> roles)
-
crud
static void crud(@NotNull() String path, @NotNull() CrudHandler crudHandler)
-
crud
static void crud(@NotNull() String path, @NotNull() CrudHandler crudHandler, @NotNull() Array<RouteRole> roles)
-
-
-
-