public class Javalin
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
JavalinConfig |
config
Do not use this field unless you know what you're doing.
|
protected EventManager |
eventManager |
static org.slf4j.Logger |
log |
protected JavalinServer |
server |
protected JavalinServlet |
servlet |
protected JavalinWsServlet |
wsServlet |
| Modifier | Constructor and Description |
|---|---|
protected |
Javalin() |
|
Javalin(JavalinServer server,
JavalinWsServlet wsServlet) |
| Modifier and Type | Method and Description |
|---|---|
Javalin |
addHandler(HandlerType httpMethod,
java.lang.String path,
Handler handler)
Adds a request handler for the specified handlerType and path to the instance.
|
Javalin |
addHandler(HandlerType handlerType,
java.lang.String path,
Handler handler,
java.util.Set<Role> roles)
Adds a request handler for the specified handlerType and path to the instance.
|
Javalin |
after(Handler handler)
Adds an AFTER request handler for all routes in the instance.
|
Javalin |
after(java.lang.String path,
Handler handler)
Adds an AFTER request handler for the specified path to the instance.
|
<T> T |
attribute(java.lang.Class<T> clazz)
Retrieve an attribute stored on the instance.
|
Javalin |
attribute(java.lang.Class clazz,
java.lang.Object obj)
Registers an attribute on the instance.
|
Javalin |
before(Handler handler)
Adds a BEFORE request handler for all routes in the instance.
|
Javalin |
before(java.lang.String path,
Handler handler)
Adds a BEFORE request handler for the specified path to the instance.
|
static Javalin |
create()
Creates a new instance without any custom configuration.
|
static Javalin |
create(java.util.function.Consumer<JavalinConfig> config)
Creates a new instance with the user provided configuration.
|
static Javalin |
createStandalone() |
static Javalin |
createStandalone(java.util.function.Consumer<JavalinConfig> config) |
Javalin |
delete(java.lang.String path,
Handler handler)
Adds a DELETE request handler for the specified path to the instance.
|
Javalin |
delete(java.lang.String path,
Handler handler,
java.util.Set<Role> permittedRoles)
Adds a DELETE request handler with the given roles for the specified path to the instance.
|
Javalin |
error(int statusCode,
Handler handler)
Adds an error mapper to the instance.
|
Javalin |
error(int statusCode,
java.lang.String contentType,
Handler handler)
Adds an error mapper for the specified content-type to the instance.
|
Javalin |
events(java.util.function.Consumer<EventListener> listener) |
<T extends java.lang.Exception> |
exception(java.lang.Class<T> exceptionClass,
ExceptionHandler<? super T> exceptionHandler)
Adds an exception mapper to the instance.
|
Javalin |
get(java.lang.String path,
Handler handler)
Adds a GET request handler for the specified path to the instance.
|
Javalin |
get(java.lang.String path,
Handler handler,
java.util.Set<Role> permittedRoles)
Adds a GET request handler with the given roles for the specified path to the instance.
|
Javalin |
head(java.lang.String path,
Handler handler)
Adds a HEAD request handler for the specified path to the instance.
|
Javalin |
head(java.lang.String path,
Handler handler,
java.util.Set<Role> permittedRoles)
Adds a HEAD request handler with the given roles for the specified path to the instance.
|
Javalin |
options(java.lang.String path,
Handler handler)
Adds a OPTIONS request handler for the specified path to the instance.
|
Javalin |
options(java.lang.String path,
Handler handler,
java.util.Set<Role> permittedRoles)
Adds a OPTIONS request handler with the given roles for the specified path to the instance.
|
Javalin |
patch(java.lang.String path,
Handler handler)
Adds a PATCH request handler for the specified path to the instance.
|
Javalin |
patch(java.lang.String path,
Handler handler,
java.util.Set<Role> permittedRoles)
Adds a PATCH request handler with the given roles for the specified path to the instance.
|
int |
port()
Get which port instance is running on
Mostly useful if you start the instance with port(0) (random port)
|
Javalin |
post(java.lang.String path,
Handler handler)
Adds a POST request handler for the specified path to the instance.
|
Javalin |
post(java.lang.String path,
Handler handler,
java.util.Set<Role> permittedRoles)
Adds a POST request handler with the given roles for the specified path to the instance.
|
Javalin |
put(java.lang.String path,
Handler handler)
Adds a PUT request handler for the specified path to the instance.
|
Javalin |
put(java.lang.String path,
Handler handler,
java.util.Set<Role> permittedRoles)
Adds a PUT request handler with the given roles for the specified path to the instance.
|
Javalin |
routes(EndpointGroup endpointGroup)
Creates a temporary static instance in the scope of the endpointGroup.
|
JavalinServer |
server()
Get the JavalinServer
|
JavalinServlet |
servlet() |
Javalin |
sse(java.lang.String path,
java.util.function.Consumer<SseClient> client)
Adds a lambda handler for a Server Sent Event connection on the specified path.
|
Javalin |
sse(java.lang.String path,
java.util.function.Consumer<SseClient> client,
java.util.Set<Role> permittedRoles)
Adds a lambda handler for a Server Sent Event connection on the specified path.
|
Javalin |
start()
Synchronously starts the application instance on the default port (7000).
|
Javalin |
start(int port)
Synchronously starts the application instance on the specified port.
|
Javalin |
start(java.lang.String host,
int port)
Synchronously starts the application instance on the specified port
with the given host IP to bind to.
|
Javalin |
stop()
Synchronously stops the application instance.
|
Javalin |
ws(java.lang.String path,
java.util.function.Consumer<WsHandler> ws)
Adds a WebSocket handler on the specified path.
|
Javalin |
ws(java.lang.String path,
java.util.function.Consumer<WsHandler> ws,
java.util.Set<Role> permittedRoles)
Adds a WebSocket handler on the specified path with the specified roles.
|
Javalin |
wsAfter(java.util.function.Consumer<WsHandler> wsHandler)
Adds a WebSocket after handler for all routes in the instance.
|
Javalin |
wsAfter(java.lang.String path,
java.util.function.Consumer<WsHandler> wsHandler)
Adds a WebSocket after handler for the specified path to the instance.
|
Javalin |
wsBefore(java.util.function.Consumer<WsHandler> wsHandler)
Adds a WebSocket before handler for all routes in the instance.
|
Javalin |
wsBefore(java.lang.String path,
java.util.function.Consumer<WsHandler> wsHandler)
Adds a WebSocket before handler for the specified path to the instance.
|
<T extends java.lang.Exception> |
wsException(java.lang.Class<T> exceptionClass,
WsExceptionHandler<? super T> exceptionHandler)
Adds a WebSocket exception mapper to the instance.
|
JavalinWsServlet |
wsServlet() |
public static org.slf4j.Logger log
public JavalinConfig config
create(Consumer)protected JavalinServer server
protected JavalinWsServlet wsServlet
protected JavalinServlet servlet
protected EventManager eventManager
protected Javalin()
public Javalin(JavalinServer server, JavalinWsServlet wsServlet)
public static Javalin create()
create(Consumer)public static Javalin create(java.util.function.Consumer<JavalinConfig> config)
start() is called.start(),
start(int)public static Javalin createStandalone(java.util.function.Consumer<JavalinConfig> config)
public static Javalin createStandalone()
public JavalinServlet servlet()
public JavalinWsServlet wsServlet()
@Nullable public JavalinServer server()
public Javalin start(java.lang.String host, int port)
public Javalin start(int port)
public Javalin start()
start(int) with port 0.create()public Javalin stop()
public Javalin events(java.util.function.Consumer<EventListener> listener)
public int port()
public Javalin attribute(java.lang.Class clazz, java.lang.Object obj)
Context through Context.appAttribute(java.lang.Class<T>).
Ex: app.attribute(MyExt.class, myExtInstance())
The method must be called before start().public <T> T attribute(java.lang.Class<T> clazz)
Context through Context.appAttribute(java.lang.Class<T>).
Ex: app.attribute(MyExt.class).myMethod()
Ex: ctx.appAttribute(MyExt.class).myMethod()public Javalin routes(@NotNull EndpointGroup endpointGroup)
ApiBuilderpublic <T extends java.lang.Exception> Javalin exception(@NotNull java.lang.Class<T> exceptionClass, @NotNull ExceptionHandler<? super T> exceptionHandler)
public Javalin error(int statusCode, @NotNull Handler handler)
public Javalin error(int statusCode, @NotNull java.lang.String contentType, @NotNull Handler handler)
public Javalin addHandler(@NotNull HandlerType handlerType, @NotNull java.lang.String path, @NotNull Handler handler, @NotNull java.util.Set<Role> roles)
AccessManager,
Handlers in docspublic Javalin addHandler(@NotNull HandlerType httpMethod, @NotNull java.lang.String path, @NotNull Handler handler)
public Javalin get(@NotNull java.lang.String path, @NotNull Handler handler)
public Javalin post(@NotNull java.lang.String path, @NotNull Handler handler)
public Javalin put(@NotNull java.lang.String path, @NotNull Handler handler)
public Javalin patch(@NotNull java.lang.String path, @NotNull Handler handler)
public Javalin delete(@NotNull java.lang.String path, @NotNull Handler handler)
public Javalin head(@NotNull java.lang.String path, @NotNull Handler handler)
public Javalin options(@NotNull java.lang.String path, @NotNull Handler handler)
public Javalin get(@NotNull java.lang.String path, @NotNull Handler handler, @NotNull java.util.Set<Role> permittedRoles)
AccessManager,
Handlers in docspublic Javalin post(@NotNull java.lang.String path, @NotNull Handler handler, @NotNull java.util.Set<Role> permittedRoles)
AccessManager,
Handlers in docspublic Javalin put(@NotNull java.lang.String path, @NotNull Handler handler, @NotNull java.util.Set<Role> permittedRoles)
AccessManager,
Handlers in docspublic Javalin patch(@NotNull java.lang.String path, @NotNull Handler handler, @NotNull java.util.Set<Role> permittedRoles)
AccessManager,
Handlers in docspublic Javalin delete(@NotNull java.lang.String path, @NotNull Handler handler, @NotNull java.util.Set<Role> permittedRoles)
AccessManager,
Handlers in docspublic Javalin head(@NotNull java.lang.String path, @NotNull Handler handler, @NotNull java.util.Set<Role> permittedRoles)
AccessManager,
Handlers in docspublic Javalin options(@NotNull java.lang.String path, @NotNull Handler handler, @NotNull java.util.Set<Role> permittedRoles)
AccessManager,
Handlers in docspublic Javalin sse(@NotNull java.lang.String path, @NotNull java.util.function.Consumer<SseClient> client)
public Javalin sse(@NotNull java.lang.String path, @NotNull java.util.function.Consumer<SseClient> client, @NotNull java.util.Set<Role> permittedRoles)
public Javalin before(@NotNull java.lang.String path, @NotNull Handler handler)
public Javalin before(@NotNull Handler handler)
public Javalin after(@NotNull java.lang.String path, @NotNull Handler handler)
public Javalin after(@NotNull Handler handler)
public <T extends java.lang.Exception> Javalin wsException(@NotNull java.lang.Class<T> exceptionClass, @NotNull WsExceptionHandler<? super T> exceptionHandler)
public Javalin ws(@NotNull java.lang.String path, @NotNull java.util.function.Consumer<WsHandler> ws)
public Javalin ws(@NotNull java.lang.String path, @NotNull java.util.function.Consumer<WsHandler> ws, @NotNull java.util.Set<Role> permittedRoles)
AccessManager,
WebSockets in docspublic Javalin wsBefore(@NotNull java.lang.String path, @NotNull java.util.function.Consumer<WsHandler> wsHandler)
public Javalin wsBefore(@NotNull java.util.function.Consumer<WsHandler> wsHandler)
public Javalin wsAfter(@NotNull java.lang.String path, @NotNull java.util.function.Consumer<WsHandler> wsHandler)
Copyright © 2021. All Rights Reserved.