-
Notifications
You must be signed in to change notification settings - Fork 38
Unified head interception #104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/main/java/io/vertx/httpproxy/interceptors/HeadInterceptor.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| /* | ||
| * Copyright (c) 2011-2024 Contributors to the Eclipse Foundation | ||
| * | ||
| * This program and the accompanying materials are made available under the | ||
| * terms of the Eclipse Public License 2.0 which is available at | ||
| * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 | ||
| * which is available at https://www.apache.org/licenses/LICENSE-2.0. | ||
| * | ||
| * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 | ||
| */ | ||
| package io.vertx.httpproxy.interceptors; | ||
|
|
||
| import io.vertx.codegen.annotations.Unstable; | ||
| import io.vertx.codegen.annotations.VertxGen; | ||
| import io.vertx.httpproxy.ProxyInterceptor; | ||
| import io.vertx.httpproxy.interceptors.impl.HeadInterceptorBuilderImpl; | ||
|
|
||
| /** | ||
| * An interceptor updating HTTP request/response head attributes (headers, path, query params). | ||
| */ | ||
| @VertxGen | ||
| @Unstable | ||
| public interface HeadInterceptor extends ProxyInterceptor { | ||
|
|
||
| /** | ||
| * @return a builder for head interception | ||
| */ | ||
| static HeadInterceptorBuilder builder() { | ||
| return new HeadInterceptorBuilderImpl(); | ||
| } | ||
| } |
134 changes: 134 additions & 0 deletions
134
src/main/java/io/vertx/httpproxy/interceptors/HeadInterceptorBuilder.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,134 @@ | ||
| /* | ||
| * Copyright (c) 2011-2024 Contributors to the Eclipse Foundation | ||
| * | ||
| * This program and the accompanying materials are made available under the | ||
| * terms of the Eclipse Public License 2.0 which is available at | ||
| * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 | ||
| * which is available at https://www.apache.org/licenses/LICENSE-2.0. | ||
| * | ||
| * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 | ||
| */ | ||
|
|
||
| package io.vertx.httpproxy.interceptors; | ||
|
|
||
| import io.vertx.codegen.annotations.Fluent; | ||
| import io.vertx.codegen.annotations.GenIgnore; | ||
| import io.vertx.codegen.annotations.Unstable; | ||
| import io.vertx.codegen.annotations.VertxGen; | ||
| import io.vertx.core.Handler; | ||
| import io.vertx.core.MultiMap; | ||
|
|
||
| import java.util.Set; | ||
| import java.util.function.Function; | ||
|
|
||
| import static io.vertx.codegen.annotations.GenIgnore.PERMITTED_TYPE; | ||
|
|
||
| /** | ||
| * Configuration for an interceptor updating HTTP request/response head attributes (headers, path, query params). | ||
| * <p> | ||
| * All configuration methods can be invoked several times. | ||
| * Operations on the path will be invoked in the order of configuration. | ||
| * That goes for operations on request headers, response headers and query parameters. | ||
| */ | ||
| @VertxGen | ||
| @Unstable | ||
| public interface HeadInterceptorBuilder { | ||
|
|
||
| /** | ||
| * @return an interceptor build according to builder requirements | ||
| */ | ||
| HeadInterceptor build(); | ||
|
|
||
| /** | ||
| * Apply modifications to the query parameters. | ||
| * | ||
| * @param updater the operation to apply to the request query parameters (can be null, but in this case nothing happens) | ||
| * @return a reference to this, so the API can be used fluently | ||
| */ | ||
| @Fluent | ||
| HeadInterceptorBuilder updatingQueryParams(Handler<MultiMap> updater); | ||
|
|
||
| /** | ||
| * Add a query parameter to the request. | ||
| * | ||
| * @param name the parameter name (can be null, but in this case nothing happens) | ||
| * @param value the parameter value (can be null, but in this case nothing happens) | ||
| * @return a reference to this, so the API can be used fluently | ||
| */ | ||
| @Fluent | ||
| HeadInterceptorBuilder settingQueryParam(String name, String value); | ||
|
|
||
| /** | ||
| * Remove a query parameter from the request. | ||
| * | ||
| * @param name the parameter name (can be null, but in this case nothing happens) | ||
| * @return a reference to this, so the API can be used fluently | ||
| */ | ||
| @Fluent | ||
| HeadInterceptorBuilder removingQueryParam(String name); | ||
|
|
||
| /** | ||
| * Apply a callback to change the request URI when the proxy receives it. | ||
| * | ||
| * @param mutator the operation that applied to the path (can be null, but in this case nothing happens) | ||
| * @return a reference to this, so the API can be used fluently | ||
| */ | ||
| @Fluent | ||
| HeadInterceptorBuilder updatingPath(Function<String, String> mutator); | ||
|
|
||
| /** | ||
| * Add a prefix to the URI. | ||
| * | ||
| * @param prefix the prefix that need to be added (can be null, but in this case nothing happens) | ||
| * @return a reference to this, so the API can be used fluently | ||
| */ | ||
| @Fluent | ||
| HeadInterceptorBuilder addingPathPrefix(String prefix); | ||
|
|
||
| /** | ||
| * Remove a prefix to the URI. Do nothing if it doesn't exist. | ||
| * | ||
| * @param prefix the prefix that need to be removed (can be null, but in this case nothing happens) | ||
| * @return a reference to this, so the API can be used fluently | ||
| */ | ||
| @Fluent | ||
| HeadInterceptorBuilder removingPathPrefix(String prefix); | ||
|
|
||
| /** | ||
| * Apply callbacks to change the request headers when the proxy receives them. | ||
| * | ||
| * @param requestHeadersUpdater the operation to apply to the request headers (can be null, but in this case nothing happens) | ||
| * @return a reference to this, so the API can be used fluently | ||
| */ | ||
| @Fluent | ||
| HeadInterceptorBuilder updatingRequestHeaders(Handler<MultiMap> requestHeadersUpdater); | ||
|
|
||
| /** | ||
| * Apply callbacks to change the response headers when the proxy receives them. | ||
| * | ||
| * @param responseHeadersUpdater the operation to apply to the response headers (can be null, but in this case nothing happens) | ||
| * @return a reference to this, so the API can be used fluently | ||
| */ | ||
| @Fluent | ||
| HeadInterceptorBuilder updatingResponseHeaders(Handler<MultiMap> responseHeadersUpdater); | ||
|
|
||
| /** | ||
| * Filter the request headers in the given set. | ||
| * | ||
| * @param forbiddenRequestHeaders a set of the headers that need to be filtered (can be null, but in this case nothing happens) | ||
| * @return a reference to this, so the API can be used fluently | ||
| */ | ||
| @GenIgnore(PERMITTED_TYPE) | ||
| @Fluent | ||
| HeadInterceptorBuilder filteringRequestHeaders(Set<CharSequence> forbiddenRequestHeaders); | ||
|
|
||
| /** | ||
| * Filter the response headers in the given set. | ||
| * | ||
| * @param forbiddenResponseHeaders a set of the headers that need to be filtered (can be null, but in this case nothing happens) | ||
| * @return a reference to this, so the API can be used fluently | ||
| */ | ||
| @GenIgnore(PERMITTED_TYPE) | ||
| @Fluent | ||
| HeadInterceptorBuilder filteringResponseHeaders(Set<CharSequence> forbiddenResponseHeaders); | ||
| } |
77 changes: 0 additions & 77 deletions
77
src/main/java/io/vertx/httpproxy/interceptors/HeadersInterceptor.java
This file was deleted.
Oops, something went wrong.
57 changes: 0 additions & 57 deletions
57
src/main/java/io/vertx/httpproxy/interceptors/PathInterceptor.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.