/** * Create a RequestContext to expose under the specified attribute name. * <p>The default implementation creates a standard RequestContext instance * for the given request and model. Can be overridden in subclasses for * custom instances. * @param exchange current exchange * @param model combined output Map (never {@code null}), * with dynamic values taking precedence over static attributes * @return the RequestContext instance * @see #setRequestContextAttribute */ protected RequestContext createRequestContext(ServerWebExchange exchange, Map<String, Object> model) { return new RequestContext(exchange, model, obtainApplicationContext(), getRequestDataValueProcessor()); }
@Test public void testGetContextUrlWithMapEscaping() throws Exception { RequestContext context = new RequestContext(this.exchange, this.model, this.applicationContext); Map<String, Object> map = new HashMap<>(); map.put("foo", "bar baz"); map.put("spam", "&bucket="); assertEquals("/foo/bar%20baz?spam=%26bucket%3D", context.getContextUrl("{foo}?spam={spam}", map)); }
@Test public void testGetContextUrlWithMap() throws Exception { RequestContext context = new RequestContext(this.exchange, this.model, this.applicationContext); Map<String, Object> map = new HashMap<>(); map.put("foo", "bar"); map.put("spam", "bucket"); assertEquals("/foo/bar?spam=bucket", context.getContextUrl("{foo}?spam={spam}", map)); }
@Test public void testGetContextUrl() throws Exception { RequestContext context = new RequestContext(this.exchange, this.model, this.applicationContext); assertEquals("/foo/bar", context.getContextUrl("bar")); }
/** * Create a RequestContext to expose under the specified attribute name. * <p>The default implementation creates a standard RequestContext instance for the * given request and model. Can be overridden in subclasses for custom instances. * @param exchange current exchange * @param model combined output Map (never {@code null}), * with dynamic values taking precedence over static attributes * @return the RequestContext instance * @see #setRequestContextAttribute */ protected RequestContext createRequestContext(ServerWebExchange exchange, Map<String, Object> model) { return new RequestContext(exchange, model, getApplicationContext(), getRequestDataValueProcessor()); }