Skip to content
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

Add support for URI's path prefix modification #952

Closed

Conversation

big-cir
Copy link

@big-cir big-cir commented Dec 27, 2024

Overview

  1. Added pathPrefix field and setter method to UriModifyingOperationPreprocessor
  2. Added corresponding support in UriModifyingContentModifier

Related Issues

#945

Test

@Test
public void requestContentUriPathIsPreservedAndAddPathPrefix() {
    this.preprocessor
		    .removePort()
		    .pathPrefix("/addPathPrefix");
    OperationRequest processed = this.preprocessor
	    .preprocess(createRequestWithContent("The uri 'http://localhost:12345/foo/bar' should be used"));
    assertThat(new String(processed.getContent())).isEqualTo("The uri 'http://localhost/addPathPrefix/foo/bar' should be used");
}

@Test
public void responseContentUriPathIsPreservedAndAddPathPrefix() {
    this.preprocessor
		    .removePort()
		    .pathPrefix("addPathPrefix");
    OperationResponse processed = this.preprocessor
	    .preprocess(createResponseWithContent("The uri 'http://localhost:12345/foo/bar' should be used"));
    assertThat(new String(processed.getContent())).isEqualTo("The uri 'http://localhost/addPathPrefix/foo/bar' should be used");
}

@wilkinsona
Copy link
Member

Thanks for PR. Unfortunately, I'm not sure that focussing solely on the path's prefix is the right approach as there may be a need to modify the path in other ways. I think we need to take a step back and consider exactly what modifications to support before looking at possible implementations. One option may be to support something like Spring Framework's UriComponentsBuilder. Another would be to allow the user to provide a UnaryOperator that's called with the current path and can return a new path modified in any way they require.

@wilkinsona wilkinsona closed this Jan 9, 2025
@wilkinsona wilkinsona added status: declined Suggestion or change that we don't want to make at this time and removed status: waiting-for-triage Untriaged issue labels Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: declined Suggestion or change that we don't want to make at this time
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants