public class Javalin
extends java.lang.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,
java.lang.String path,
Handler handler)
Adds a request handler for the specified handlerType and path to the instance.
|
Javalin |
addHandler(io.javalin.http.HandlerType handlerType,
java.lang.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(java.lang.String path,
Handler handler)
Adds an AFTER request handler for the specified path to the instance.
|
<T> T |
attribute(java.lang.String key)
Retrieve an attribute stored on the instance.
|
Javalin |
attribute(java.lang.String key,
java.lang.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(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,
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,
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,
RouteRole... roles)
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,
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(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,
RouteRole... roles)
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,
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(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,
RouteRole... roles)
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,
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(java.lang.String path,
java.util.function.Consumer<io.javalin.http.sse.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<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(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<WsConfig> ws)
Adds a WebSocket handler on the specified path.
|
Javalin |
ws(java.lang.String path,
java.util.function.Consumer<WsConfig> ws,
RouteRole... roles)
Adds a WebSocket handler on the specified path with the specified roles.
|
Javalin |
wsAfter(java.util.function.Consumer<WsConfig> wsConfig)
Adds a WebSocket after handler for all routes in the instance.
|
Javalin |
wsAfter(java.lang.String path,
java.util.function.Consumer<WsConfig> wsConfig)
Adds a WebSocket after handler for the specified path to the instance.
|
Javalin |
wsBefore(java.util.function.Consumer<WsConfig> wsConfig)
Adds a WebSocket before handler for all routes in the instance.
|
Javalin |
wsBefore(java.lang.String path,
java.util.function.Consumer<WsConfig> wsConfig)
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.
|
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(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 io.javalin.http.JavalinServlet javalinServlet()
@Nullable public io.javalin.jetty.JettyServer jettyServer()
public Javalin start(java.lang.String host, int port)
public Javalin start(int port)
public Javalin start()
create()
public Javalin stop()
public Javalin events(java.util.function.Consumer<EventListener> listener)
public int port()
public Javalin attribute(java.lang.String key, java.lang.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(java.lang.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)
ApiBuilder
public <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 io.javalin.http.HandlerType handlerType, @NotNull java.lang.String path, @NotNull Handler handler, @NotNull RouteRole... roles)
AccessManager
,
Handlers in docspublic Javalin addHandler(@NotNull io.javalin.http.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 RouteRole... roles)
AccessManager
,
Handlers in docspublic Javalin post(@NotNull java.lang.String path, @NotNull Handler handler, @NotNull RouteRole... roles)
AccessManager
,
Handlers in docspublic Javalin put(@NotNull java.lang.String path, @NotNull Handler handler, @NotNull RouteRole... roles)
AccessManager
,
Handlers in docspublic Javalin patch(@NotNull java.lang.String path, @NotNull Handler handler, @NotNull RouteRole... roles)
AccessManager
,
Handlers in docspublic Javalin delete(@NotNull java.lang.String path, @NotNull Handler handler, @NotNull RouteRole... roles)
AccessManager
,
Handlers in docspublic Javalin head(@NotNull java.lang.String path, @NotNull Handler handler, @NotNull RouteRole... roles)
AccessManager
,
Handlers in docspublic Javalin options(@NotNull java.lang.String path, @NotNull Handler handler, @NotNull RouteRole... roles)
AccessManager
,
Handlers in docspublic Javalin sse(@NotNull java.lang.String path, @NotNull java.util.function.Consumer<io.javalin.http.sse.SseClient> client)
public Javalin sse(@NotNull java.lang.String path, @NotNull java.util.function.Consumer<io.javalin.http.sse.SseClient> client, @NotNull RouteRole... roles)
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<WsConfig> ws)
public Javalin ws(@NotNull java.lang.String path, @NotNull java.util.function.Consumer<WsConfig> ws, @NotNull RouteRole... roles)
AccessManager
,
WebSockets in docspublic Javalin wsBefore(@NotNull java.lang.String path, @NotNull java.util.function.Consumer<WsConfig> wsConfig)
public Javalin wsBefore(@NotNull java.util.function.Consumer<WsConfig> wsConfig)
public Javalin wsAfter(@NotNull java.lang.String path, @NotNull java.util.function.Consumer<WsConfig> wsConfig)
Copyright © 2021. All Rights Reserved.