|
| 1 | +/* |
| 2 | + * Copyright (c) 2011-2024 Contributors to the Eclipse Foundation |
| 3 | + * |
| 4 | + * This program and the accompanying materials are made available under the |
| 5 | + * terms of the Eclipse Public License 2.0 which is available at |
| 6 | + * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 |
| 7 | + * which is available at https://www.apache.org/licenses/LICENSE-2.0. |
| 8 | + * |
| 9 | + * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 |
| 10 | + */ |
| 11 | + |
| 12 | +package io.vertx.httpproxy.interceptors; |
| 13 | + |
| 14 | +import io.vertx.codegen.annotations.Fluent; |
| 15 | +import io.vertx.codegen.annotations.GenIgnore; |
| 16 | +import io.vertx.codegen.annotations.Unstable; |
| 17 | +import io.vertx.codegen.annotations.VertxGen; |
| 18 | +import io.vertx.core.Handler; |
| 19 | +import io.vertx.core.MultiMap; |
| 20 | + |
| 21 | +import java.util.Set; |
| 22 | +import java.util.function.Function; |
| 23 | + |
| 24 | +import static io.vertx.codegen.annotations.GenIgnore.PERMITTED_TYPE; |
| 25 | + |
| 26 | +/** |
| 27 | + * Configuration for an interceptor updating HTTP request/response head attributes (headers, path, query params). |
| 28 | + * <p> |
| 29 | + * All configuration methods can be invoked several times. |
| 30 | + * Operations on the path will be invoked in the order of configuration. |
| 31 | + * That goes for operations on request headers, response headers and query parameters. |
| 32 | + */ |
| 33 | +@VertxGen |
| 34 | +@Unstable |
| 35 | +public interface HeadInterceptorBuilder { |
| 36 | + |
| 37 | + /** |
| 38 | + * @return an interceptor build according to builder requirements |
| 39 | + */ |
| 40 | + HeadInterceptor build(); |
| 41 | + |
| 42 | + /** |
| 43 | + * Apply modifications to the query parameters. |
| 44 | + * |
| 45 | + * @param updater the operation to apply to the request query parameters (can be null, but in this case nothing happens) |
| 46 | + * @return a reference to this, so the API can be used fluently |
| 47 | + */ |
| 48 | + @Fluent |
| 49 | + HeadInterceptorBuilder updatingQueryParams(Handler<MultiMap> updater); |
| 50 | + |
| 51 | + /** |
| 52 | + * Add a query parameter to the request. |
| 53 | + * |
| 54 | + * @param name the parameter name (can be null, but in this case nothing happens) |
| 55 | + * @param value the parameter value (can be null, but in this case nothing happens) |
| 56 | + * @return a reference to this, so the API can be used fluently |
| 57 | + */ |
| 58 | + @Fluent |
| 59 | + HeadInterceptorBuilder settingQueryParam(String name, String value); |
| 60 | + |
| 61 | + /** |
| 62 | + * Remove a query parameter from the request. |
| 63 | + * |
| 64 | + * @param name the parameter name (can be null, but in this case nothing happens) |
| 65 | + * @return a reference to this, so the API can be used fluently |
| 66 | + */ |
| 67 | + @Fluent |
| 68 | + HeadInterceptorBuilder removingQueryParam(String name); |
| 69 | + |
| 70 | + /** |
| 71 | + * Apply a callback to change the request URI when the proxy receives it. |
| 72 | + * |
| 73 | + * @param mutator the operation that applied to the path (can be null, but in this case nothing happens) |
| 74 | + * @return a reference to this, so the API can be used fluently |
| 75 | + */ |
| 76 | + @Fluent |
| 77 | + HeadInterceptorBuilder updatingPath(Function<String, String> mutator); |
| 78 | + |
| 79 | + /** |
| 80 | + * Add a prefix to the URI. |
| 81 | + * |
| 82 | + * @param prefix the prefix that need to be added (can be null, but in this case nothing happens) |
| 83 | + * @return a reference to this, so the API can be used fluently |
| 84 | + */ |
| 85 | + @Fluent |
| 86 | + HeadInterceptorBuilder addingPathPrefix(String prefix); |
| 87 | + |
| 88 | + /** |
| 89 | + * Remove a prefix to the URI. Do nothing if it doesn't exist. |
| 90 | + * |
| 91 | + * @param prefix the prefix that need to be removed (can be null, but in this case nothing happens) |
| 92 | + * @return a reference to this, so the API can be used fluently |
| 93 | + */ |
| 94 | + @Fluent |
| 95 | + HeadInterceptorBuilder removingPathPrefix(String prefix); |
| 96 | + |
| 97 | + /** |
| 98 | + * Apply callbacks to change the request headers when the proxy receives them. |
| 99 | + * |
| 100 | + * @param requestHeadersUpdater the operation to apply to the request headers (can be null, but in this case nothing happens) |
| 101 | + * @return a reference to this, so the API can be used fluently |
| 102 | + */ |
| 103 | + @Fluent |
| 104 | + HeadInterceptorBuilder updatingRequestHeaders(Handler<MultiMap> requestHeadersUpdater); |
| 105 | + |
| 106 | + /** |
| 107 | + * Apply callbacks to change the response headers when the proxy receives them. |
| 108 | + * |
| 109 | + * @param responseHeadersUpdater the operation to apply to the response headers (can be null, but in this case nothing happens) |
| 110 | + * @return a reference to this, so the API can be used fluently |
| 111 | + */ |
| 112 | + @Fluent |
| 113 | + HeadInterceptorBuilder updatingResponseHeaders(Handler<MultiMap> responseHeadersUpdater); |
| 114 | + |
| 115 | + /** |
| 116 | + * Filter the request headers in the given set. |
| 117 | + * |
| 118 | + * @param forbiddenRequestHeaders a set of the headers that need to be filtered (can be null, but in this case nothing happens) |
| 119 | + * @return a reference to this, so the API can be used fluently |
| 120 | + */ |
| 121 | + @GenIgnore(PERMITTED_TYPE) |
| 122 | + @Fluent |
| 123 | + HeadInterceptorBuilder filteringRequestHeaders(Set<CharSequence> forbiddenRequestHeaders); |
| 124 | + |
| 125 | + /** |
| 126 | + * Filter the response headers in the given set. |
| 127 | + * |
| 128 | + * @param forbiddenResponseHeaders a set of the headers that need to be filtered (can be null, but in this case nothing happens) |
| 129 | + * @return a reference to this, so the API can be used fluently |
| 130 | + */ |
| 131 | + @GenIgnore(PERMITTED_TYPE) |
| 132 | + @Fluent |
| 133 | + HeadInterceptorBuilder filteringResponseHeaders(Set<CharSequence> forbiddenResponseHeaders); |
| 134 | +} |
0 commit comments