io.undertow.server.handlers.PredicateHandler Java Examples
The following examples show how to use
io.undertow.server.handlers.PredicateHandler.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FormAuthTestCase.java From quarkus-http with Apache License 2.0 | 5 votes |
@Override protected void setRootHandler(HttpHandler current) { final PredicateHandler handler = new PredicateHandler(Predicates.path("/login"), new HttpHandler() { @Override public void handleRequest(HttpServerExchange exchange) throws Exception { exchange.writeAsync("Login Page"); } }, current); super.setRootHandler(new SessionAttachmentHandler(handler, new InMemorySessionManager("test"), new SessionCookieConfig())); }
Example #2
Source File: DomainUtil.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
static ResourceHandlerDefinition createStaticContentHandler(ResourceManager resource, String context) { final io.undertow.server.handlers.resource.ResourceHandler handler = new io.undertow.server.handlers.resource.ResourceHandler(resource) .setCacheTime(60 * 60 * 24 * 31) .setAllowed(not(path("META-INF"))) .setResourceManager(resource) .setDirectoryListingEnabled(false) .setCachable(not(suffixes(NOCACHE_JS, APP_HTML, INDEX_HTML))); // avoid clickjacking attacks: console must not be included in (i)frames SetHeaderHandler frameHandler = new SetHeaderHandler(handler, "X-Frame-Options", "SAMEORIGIN"); // we also need to setup the default resource redirect PredicateHandler predicateHandler = new PredicateHandler(path("/"), new RedirectHandler(ExchangeAttributes.constant(context + DEFAULT_RESOURCE)), frameHandler); return new ResourceHandlerDefinition(context, DEFAULT_RESOURCE, predicateHandler); }
Example #3
Source File: ConsoleMode.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
static ResourceHandlerDefinition createConsoleHandler(String slot, String resource) throws ModuleLoadException { final ClassPathResourceManager cpresource = new ClassPathResourceManager(getClassLoader(Module.getCallerModuleLoader(), ERROR_MODULE, slot), ""); final io.undertow.server.handlers.resource.ResourceHandler handler = new io.undertow.server.handlers.resource.ResourceHandler(cpresource) .setAllowed(not(path("META-INF"))) .setResourceManager(cpresource) .setDirectoryListingEnabled(false) .setCachable(Predicates.<HttpServerExchange>falsePredicate()); //we also need to setup the default resource redirect PredicateHandler predicateHandler = new PredicateHandler(path("/"), new RedirectHandler(ExchangeAttributes.constant(CONTEXT + resource)), handler); return new ResourceHandlerDefinition(CONTEXT, resource, predicateHandler); }
Example #4
Source File: ErrorContextHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
public static HttpHandler createErrorContext(final String slot) throws ModuleLoadException { final ClassPathResourceManager cpresource = new ClassPathResourceManager(getClassLoader(Module.getCallerModuleLoader(), ERROR_MODULE, slot), ""); final io.undertow.server.handlers.resource.ResourceHandler handler = new io.undertow.server.handlers.resource.ResourceHandler(cpresource) .setAllowed(not(path("META-INF"))) .setDirectoryListingEnabled(false) .setCachable(Predicates.<HttpServerExchange>falsePredicate()); //we also need to setup the default resource redirect return new PredicateHandler(path("/"), new RedirectHandler(ExchangeAttributes.constant(ERROR_CONTEXT + DEFAULT_RESOURCE)), handler); }