-
Notifications
You must be signed in to change notification settings - Fork 85
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 withUrl(String) #268
Add withUrl(String) #268
Conversation
I see MiMa failing (correctly for 1.0.0). Is master the right branch for 2.0.0?
|
@gmethvin @marcospereira, you tagged #264 as help wanted. Is this what you had in mind? What are next steps? |
I think it looks fine, but we should also update the Java API. It's OK to mutate the variable in the Java API since the API is mutable. Ideally we'd have an immutable API for Java as well but it's probably not worth the breaking change. |
Thanks, I'll do that today and push to this PR. |
Speaking of breaking changes, adding the withUrl method to the trait counts as a breaking change from MiMa's perspective. (Other implementations may not have implemented it.) Would we merge this with a failing CI build? Any validations I should should be doing locally besides |
Java API updated. |
@gmethvin @marcospereira how's it look now? |
I think this can go in the next major release, where we'd allow a breaking change. So you can add a MiMa exclusion, but we just don't want to backport. |
Done. Passing build. Holler if you want me to squash. |
Bump. What's the next step for this PR? |
@marcospereira can we get this in for 2.0.0-M4? |
Freshly squashed per checklist. |
play-ahc-ws-standalone/src/test/scala/play/libs/ws/ahc/AhcWSRequestSpec.scala
Outdated
Show resolved
Hide resolved
play-ahc-ws-standalone/src/test/scala/play/api/libs/ws/ahc/AhcWSRequestSpec.scala
Outdated
Show resolved
Hide resolved
7894c84
to
8361d9a
Compare
Thanks for the review, @cchantep. Fixed. |
Would you like any other changes or can this be merged? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -225,6 +225,12 @@ public StandaloneAhcWSRequest setContentType(String contentType) { | |||
return getHeader(CONTENT_TYPE); | |||
} | |||
|
|||
@Override | |||
public StandaloneWSRequest setUrl(String url) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Return StandaloneAhcWSRequest
instead.
@@ -183,6 +183,8 @@ case class StandaloneAhcWSRequest( | |||
withMethod(method).execute() | |||
} | |||
|
|||
override def withUrl(url: String): StandaloneWSRequest = copy(url = url) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Return Self
instead.
Done and squashed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, @htmldoug.
And thanks for the patience here too.
Pull Request Checklist
Fixes
Fixes #264
Purpose
Adds support in the scala API for changing the
url
of theWSRequest
.Background Context
Like @gmethvin, I've encountered a couple use cases where I'd like to modify the URL of an existing WSRequest.
Fixing URIs
In my
WSRequestFilter
s, I'd like to make use ofWSRequest.uri
, but it's unsafe (see StandaloneWSClient.url(String) permits inconsistent states with query params #267). Today, I have aWSRequestFilter
to sanitize the entire request prior to subsequent WSRequestFilters touchingWSRequest.uri
. In order to strip out query params and any other garbage from the URL, myWSRequestFilter
has to rebuild the whole request from scratch. Additionally, it has to require aWSClient
to do the job (wsClient.url()
), which I hope is the sameWSClient
that originally used to build the request. Ugh!Changing hostnames
We're cursed with https://github.com/mesosphere/marathon-lb, which sometimes fails to route requests. I'd love to be able to have a
WSRequestFilter
I can use to bypass that layer and rewrite https://pray-marathon-lb-works.example.com/foo to https://10.0.0.25/foo.