@Override
	public GatewayFilter apply(Config config) {
		return new GatewayFilter() {
			final UriTemplate uriTemplate = new UriTemplate(config.prefix);

			@Override
			public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
				boolean alreadyPrefixed = exchange.getAttributeOrDefault(GATEWAY_ALREADY_PREFIXED_ATTR, false);
				if (alreadyPrefixed) {
					return chain.filter(exchange);
				}
				exchange.getAttributes().put(GATEWAY_ALREADY_PREFIXED_ATTR, true);

				ServerHttpRequest req = exchange.getRequest();
				addOriginalRequestUrl(exchange, req.getURI());

				Map<String, String> uriVariables = getUriTemplateVariables(exchange);
				URI uri = uriTemplate.expand(uriVariables);

				String newPath = uri.getRawPath() + req.getURI().getRawPath();
				exchange.getAttributes().put(GATEWAY_REQUEST_URL_ATTR, uri);
				ServerHttpRequest request = req.mutate().path(newPath).build();

				if (log.isTraceEnabled()) {
					log.trace("Prefixed URI with: " + config.prefix + " -> " + request.getURI());
				}

				return chain.filter(exchange.mutate().request(request).build());
			}

			@Override
			public String toString() {
				return filterToStringCreator(PrefixPathGatewayFilterFactory.this).append("prefix", config.getPrefix())
					.toString();
			}
		};
	}
@Test
	public void toStringFormat() {
		Config config = new Config();
		config.setPrefix("myprefix");
		GatewayFilter filter = new PrefixPathGatewayFilterFactory().apply(config);
		assertThat(filter.toString()).contains("myprefix");
	}