use of io.javalin.http.ContextResolver in project javalin by tipsy.
the class JavalinConfig method applyUserConfig.
public static void applyUserConfig(Javalin app, JavalinConfig config, Consumer<JavalinConfig> userConfig) {
// apply user config to the default config
userConfig.accept(config);
AtomicBoolean anyHandlerAdded = new AtomicBoolean(false);
app.events(listener -> {
listener.handlerAdded(x -> anyHandlerAdded.set(true));
listener.wsHandlerAdded(x -> anyHandlerAdded.set(true));
});
config.getPluginsExtending(PluginLifecycleInit.class).forEach(plugin -> {
plugin.init(app);
if (anyHandlerAdded.get()) {
// check if any "init" added a handler
throw new PluginInitLifecycleViolationException(((Plugin) plugin).getClass());
}
});
config.inner.plugins.values().forEach(plugin -> plugin.apply(app));
if (config.enforceSsl) {
app.before(SecurityUtil::sslRedirect);
}
config.inner.appAttributes.putIfAbsent(JSON_MAPPER_KEY, new JavalinJackson());
app.attribute(maxRequestSizeKey, config.maxRequestSize);
config.inner.appAttributes.putIfAbsent(CONTEXT_RESOLVER_KEY, new ContextResolver());
}
use of io.javalin.http.ContextResolver in project javalin by tipsy.
the class JavalinConfig method contextResolvers.
public void contextResolvers(@NotNull Consumer<ContextResolver> userResolver) {
ContextResolver finalResolver = new ContextResolver();
userResolver.accept(finalResolver);
inner.appAttributes.put(CONTEXT_RESOLVER_KEY, finalResolver);
}
Aggregations