/** * Set the {@link Condition} of this {@link Rule} instance. */ public RuleBuilder when(final Condition condition) { if (this.condition == null) this.condition = condition; else if (condition instanceof ConditionBuilder) this.condition = ((ConditionBuilder) this.condition).and(condition); else this.condition = Conditions.wrap(this.condition).and(condition); return this; }
/** * Set the {@link Condition} of this {@link Rule} instance. */ public RuleBuilder when(final Condition condition) { if (this.condition == null) this.condition = condition; else if (condition instanceof ConditionBuilder) this.condition = ((ConditionBuilder) this.condition).and(condition); else this.condition = Conditions.wrap(this.condition).and(condition); return this; }
@Override public Join to(final String resource) { if (this.resourcePattern != null) { throw new IllegalStateException("Cannot set resource path more than once."); } this.resourcePattern = resource; this.resourcePath = Path.matches(resource); Set<String> parameters = getPathRequestParameters(); if (outboundConditionCache == null) { this.outboundConditionCache = resourcePath; for (String name : parameters) { Query parameter = Query.parameterExists(name); outboundConditionCache = outboundConditionCache.and(parameter); } } return this; }
@Override public Join to(final String resource) { if (this.resourcePattern != null) { throw new IllegalStateException("Cannot set resource path more than once."); } this.resourcePattern = resource; this.resourcePath = Path.matches(resource); Set<String> parameters = getPathRequestParameters(); if (outboundConditionCache == null) { this.outboundConditionCache = resourcePath; for (String name : parameters) { Query parameter = Query.parameterExists(name); outboundConditionCache = outboundConditionCache.and(parameter); } } return this; }
@Override public Join to(final String resource) { if (this.resourcePattern != null) { throw new IllegalStateException("Cannot set resource path more than once."); } this.resourcePattern = resource; this.resourcePath = Path.matches(resource); Set<String> parameters = getPathRequestParameters(); if (outboundConditionCache == null) { this.outboundConditionCache = resourcePath; for (String name : parameters) { Query parameter = Query.parameterExists(name); outboundConditionCache = outboundConditionCache.and(parameter); } } return this; }
@Override protected Configuration narrow(ExampleConfiguration appConfiguration) { if (appConfiguration != null && !Collections.isEmpty(appConfiguration.angularjsRoutes) ) { Set<String> paths = new HashSet<>(appConfiguration.angularjsRoutes); return ConfigurationBuilder.begin() .addRule() .when( Direction.isInbound() .and(Path.matches("/{path}")) .and(matchesAnyOfPaths(paths)) ) .perform( Log.message(Logger.Level.DEBUG, "Forwarding to index.html from {path}") .and(Forward.to("/index.html")) ); } return null; }