-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
[doc] Add example of using WS from main #6594
[doc] Add example of using WS from main #6594
Conversation
c23d7ed
to
35a9b00
Compare
Adds documentation and examples for using WS standalone. Adds notes to use Play's Timeout feature.
35a9b00
to
f08d5c1
Compare
|
||
WSClient client = new AhcWSClient(config, materializer); | ||
client.url("http://www.google.com").get().whenComplete((r, e) -> { | ||
Optional.of(r).ifPresent(response -> { |
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.
Shouldn't we use Optional.ofNullable
here?
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.
...wow. It did not occur to me Optional.of
was not the same as Option()
.
println(response.allHeaders) | ||
}.andThen { | ||
case _ => | ||
wsClient.close() |
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.
We should probably do this in main
. The way it's structured now makes it look like close
should happen on every call.
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.
Done.
Needs backport to 2.5.x |
* Add WSClient standalone and timeout docs Adds documentation and examples for using WS standalone. Adds notes to use Play's Timeout feature. * Add Optional.ofNullable, clean up andThen
* Add WSClient standalone and timeout docs Adds documentation and examples for using WS standalone. Adds notes to use Play's Timeout feature. * Add Optional.ofNullable, clean up andThen
* Add WSClient standalone and timeout docs Adds documentation and examples for using WS standalone. Adds notes to use Play's Timeout feature. * Add Optional.ofNullable, clean up andThen
Adds a description of using Play WS from a main method in the simple case, with no bells or whistles.