public class Javalin extends Object
| Modifier and Type | Field and Description |
|---|---|
JavalinConfig |
_conf
Do not use this field unless you know what you're doing.
|
protected io.javalin.core.event.EventManager |
eventManager |
protected io.javalin.jetty.JavalinJettyServlet |
javalinJettyServlet |
protected io.javalin.http.JavalinServlet |
javalinServlet |
protected io.javalin.jetty.JettyServer |
jettyServer |
| Modifier | Constructor and Description |
|---|---|
protected |
Javalin() |
|
Javalin(io.javalin.jetty.JettyServer jettyServer,
io.javalin.jetty.JavalinJettyServlet jettyServlet) |
| Modifier and Type | Method and Description |
|---|---|
Javalin |
addHandler(io.javalin.http.HandlerType httpMethod,
String path,
Handler handler)
Adds a request handler for the specified handlerType and path to the instance.
|
Javalin |
addHandler(io.javalin.http.HandlerType handlerType,
String path,
Handler handler,
RouteRole... 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(String path,
Handler handler)
Adds an AFTER request handler for the specified path to the instance.
|
<T> T |
attribute(String key)
Retrieve an attribute stored on the instance.
|
Javalin |
attribute(String key,
Object value)
Registers an attribute on the instance.
|
Javalin |
before(Handler handler)
Adds a BEFORE request handler for all routes in the instance.
|
Javalin |
before(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(Consumer<JavalinConfig> config)
Creates a new instance with the user provided configuration.
|
static Javalin |
createStandalone() |
static Javalin |
createStandalone(Consumer<JavalinConfig> config) |
Javalin |
delete(String path,
Handler handler)
Adds a DELETE request handler for the specified path to the instance.
|
Javalin |
delete(String path,
Handler handler,
RouteRole... roles)
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,
String contentType,
Handler handler)
Adds an error mapper for the specified content-type to the instance.
|
Javalin |
events(Consumer<EventListener> listener) |
<T extends Exception> |
exception(Class<T> exceptionClass,
ExceptionHandler<? super T> exceptionHandler)
Adds an exception mapper to the instance.
|
Javalin |
get(String path,
Handler handler)
Adds a GET request handler for the specified path to the instance.
|
Javalin |
get(String path,
Handler handler,
RouteRole... roles)
Adds a GET request handler with the given roles for the specified path to the instance.
|
Javalin |
head(String path,
Handler handler)
Adds a HEAD request handler for the specified path to the instance.
|
Javalin |
head(String path,
Handler handler,
RouteRole... roles)
Adds a HEAD request handler with the given roles for the specified path to the instance.
|
io.javalin.http.JavalinServlet |
javalinServlet() |
io.javalin.jetty.JettyServer |
jettyServer() |
Javalin |
options(String path,
Handler handler)
Adds a OPTIONS request handler for the specified path to the instance.
|
Javalin |
options(String path,
Handler handler,
RouteRole... roles)
Adds a OPTIONS request handler with the given roles for the specified path to the instance.
|
Javalin |
patch(String path,
Handler handler)
Adds a PATCH request handler for the specified path to the instance.
|
Javalin |
patch(String path,
Handler handler,
RouteRole... roles)
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(String path,
Handler handler)
Adds a POST request handler for the specified path to the instance.
|
Javalin |
post(String path,
Handler handler,
RouteRole... roles)
Adds a POST request handler with the given roles for the specified path to the instance.
|
Javalin |
put(String path,
Handler handler)
Adds a PUT request handler for the specified path to the instance.
|
Javalin |
put(String path,
Handler handler,
RouteRole... roles)
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.
|
Javalin |
sse(String path,
Consumer<io.javalin.http.sse.SseClient> client)
Adds a lambda handler for a Server Sent Event connection on the specified path.
|
Javalin |
sse(String path,
Consumer<io.javalin.http.sse.SseClient> client,
RouteRole... roles)
Adds a lambda handler for a Server Sent Event connection on the specified path.
|
Javalin |
start()
Synchronously starts the application instance on the configured port, or on
the configured ServerConnectors if the Jetty server has been manually configured.
|
Javalin |
start(int port)
Synchronously starts the application instance on the specified port.
|
Javalin |
start(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(String path,
Consumer<WsConfig> ws)
Adds a WebSocket handler on the specified path.
|
Javalin |
ws(String path,
Consumer<WsConfig> ws,
RouteRole... roles)
Adds a WebSocket handler on the specified path with the specified roles.
|
Javalin |
wsAfter(Consumer<WsConfig> wsConfig)
Adds a WebSocket after handler for all routes in the instance.
|
Javalin |
wsAfter(String path,
Consumer<WsConfig> wsConfig)
Adds a WebSocket after handler for the specified path to the instance.
|
Javalin |
wsBefore(Consumer<WsConfig> wsConfig)
Adds a WebSocket before handler for all routes in the instance.
|
Javalin |
wsBefore(String path,
Consumer<WsConfig> wsConfig)
Adds a WebSocket before handler for the specified path to the instance.
|
<T extends Exception> |
wsException(Class<T> exceptionClass,
WsExceptionHandler<? super T> exceptionHandler)
Adds a WebSocket exception mapper to the instance.
|
public JavalinConfig _conf
create(Consumer)protected io.javalin.jetty.JettyServer jettyServer
protected io.javalin.jetty.JavalinJettyServlet javalinJettyServlet
protected io.javalin.http.JavalinServlet javalinServlet
protected io.javalin.core.event.EventManager eventManager
protected Javalin()
public Javalin(io.javalin.jetty.JettyServer jettyServer,
io.javalin.jetty.JavalinJettyServlet jettyServlet)
public static Javalin create()
create(Consumer)public static Javalin create(Consumer<JavalinConfig> config)
start() is called.start(),
start(int)public static Javalin createStandalone(Consumer<JavalinConfig> config)
public static Javalin createStandalone()
public io.javalin.http.JavalinServlet javalinServlet()
@Nullable public io.javalin.jetty.JettyServer jettyServer()
public Javalin start(String host, int port)
public Javalin start(int port)
public Javalin start()
create()public Javalin stop()
public Javalin events(Consumer<EventListener> listener)
public int port()
public Javalin attribute(String key, Object value)
Context through Context.appAttribute(java.lang.String).
Ex: app.attribute(MyExt.class, myExtInstance())
The method must be called before start().public <T> T attribute(String key)
Context through Context.appAttribute(java.lang.String).
Ex: app.attribute(MyExt.class).myMethod()
Ex: ctx.appAttribute(MyExt.class).myMethod()public Javalin routes(@NotNull EndpointGroup endpointGroup)
ApiBuilderpublic <T extends Exception> Javalin exception(@NotNull Class<T> exceptionClass, @NotNull ExceptionHandler<? super T> exceptionHandler)
public Javalin error(int statusCode, @NotNull Handler handler)
public Javalin error(int statusCode, @NotNull String contentType, @NotNull Handler handler)
public Javalin addHandler(@NotNull io.javalin.http.HandlerType handlerType, @NotNull String path, @NotNull Handler handler, @NotNull RouteRole... roles)
AccessManager,
Handlers in docspublic Javalin addHandler(@NotNull io.javalin.http.HandlerType httpMethod, @NotNull String path, @NotNull Handler handler)
public Javalin get(@NotNull String path, @NotNull Handler handler)
public Javalin post(@NotNull String path, @NotNull Handler handler)
public Javalin put(@NotNull String path, @NotNull Handler handler)
public Javalin patch(@NotNull String path, @NotNull Handler handler)
public Javalin delete(@NotNull String path, @NotNull Handler handler)
public Javalin head(@NotNull String path, @NotNull Handler handler)
public Javalin options(@NotNull String path, @NotNull Handler handler)
public Javalin get(@NotNull String path, @NotNull Handler handler, @NotNull RouteRole... roles)
AccessManager,
Handlers in docspublic Javalin post(@NotNull String path, @NotNull Handler handler, @NotNull RouteRole... roles)
AccessManager,
Handlers in docspublic Javalin put(@NotNull String path, @NotNull Handler handler, @NotNull RouteRole... roles)
AccessManager,
Handlers in docspublic Javalin patch(@NotNull String path, @NotNull Handler handler, @NotNull RouteRole... roles)
AccessManager,
Handlers in docspublic Javalin delete(@NotNull String path, @NotNull Handler handler, @NotNull RouteRole... roles)
AccessManager,
Handlers in docspublic Javalin head(@NotNull String path, @NotNull Handler handler, @NotNull RouteRole... roles)
AccessManager,
Handlers in docspublic Javalin options(@NotNull String path, @NotNull Handler handler, @NotNull RouteRole... roles)
AccessManager,
Handlers in docspublic Javalin sse(@NotNull String path, @NotNull Consumer<io.javalin.http.sse.SseClient> client)
public Javalin sse(@NotNull String path, @NotNull Consumer<io.javalin.http.sse.SseClient> client, @NotNull RouteRole... roles)
public Javalin before(@NotNull String path, @NotNull Handler handler)
public Javalin before(@NotNull Handler handler)
public Javalin after(@NotNull String path, @NotNull Handler handler)
public Javalin after(@NotNull Handler handler)
public <T extends Exception> Javalin wsException(@NotNull Class<T> exceptionClass, @NotNull WsExceptionHandler<? super T> exceptionHandler)
public Javalin ws(@NotNull String path, @NotNull Consumer<WsConfig> ws)
public Javalin ws(@NotNull String path, @NotNull Consumer<WsConfig> ws, @NotNull RouteRole... roles)
AccessManager,
WebSockets in docspublic Javalin wsBefore(@NotNull String path, @NotNull Consumer<WsConfig> wsConfig)
public Javalin wsBefore(@NotNull Consumer<WsConfig> wsConfig)
public Javalin wsAfter(@NotNull String path, @NotNull Consumer<WsConfig> wsConfig)
Copyright © 2021. All rights reserved.