-
Notifications
You must be signed in to change notification settings - Fork 366
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
Update Client interface #56
Merged
Merged
Changes from 2 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
d274582
Remove extensions of request and response
donny-dont bb81377
Update client interface
donny-dont 9764158
Update async to include collectBytes
donny-dont cf91544
Implement updated interface in BaseClient
donny-dont 949bb56
Update helper functions
donny-dont 6cf06ea
Use Future in http helpers
donny-dont 6df8771
Modify Request to take dynamic for urls
donny-dont 07dd399
Remove uses of FutureOr
donny-dont 69df648
Update version
donny-dont 35a765c
Use dev for version
donny-dont 8d2e503
Move url to utils and add additional documentation
donny-dont 362ad9c
Fix a typo.
nex3 4285911
Merge branch 'master' into feature/client-interface
nex3 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 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 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 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 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 |
---|---|---|
|
@@ -30,12 +30,12 @@ class Request extends Message { | |
/// | ||
/// Extra [context] can be used to pass information between inner middleware | ||
/// and handlers. | ||
Request(this.method, this.url, | ||
Request(String method, url, | ||
{body, | ||
Encoding encoding, | ||
Map<String, String> headers, | ||
Map<String, Object> context}) | ||
: super(body, encoding: encoding, headers: headers, context: context); | ||
: this._(method, _uri(url), body, encoding, headers, context); | ||
|
||
/// Creates a new HEAD [Request] to [url]. | ||
/// | ||
|
@@ -44,7 +44,7 @@ class Request extends Message { | |
/// | ||
/// Extra [context] can be used to pass information between inner middleware | ||
/// and handlers. | ||
Request.head(Uri url, | ||
Request.head(url, | ||
{Map<String, String> headers, Map<String, Object> context}) | ||
: this('HEAD', url, headers: headers, context: context); | ||
|
||
|
@@ -55,7 +55,7 @@ class Request extends Message { | |
/// | ||
/// Extra [context] can be used to pass information between inner middleware | ||
/// and handlers. | ||
Request.get(Uri url, | ||
Request.get(url, | ||
{Map<String, String> headers, Map<String, Object> context}) | ||
: this('GET', url, headers: headers, context: context); | ||
|
||
|
@@ -70,8 +70,7 @@ class Request extends Message { | |
/// | ||
/// Extra [context] can be used to pass information between inner middleware | ||
/// and handlers. | ||
Request.post(Uri url, | ||
body, | ||
Request.post(url, body, | ||
{Encoding encoding, | ||
Map<String, String> headers, | ||
Map<String, Object> context}) | ||
|
@@ -90,8 +89,7 @@ class Request extends Message { | |
/// | ||
/// Extra [context] can be used to pass information between inner middleware | ||
/// and handlers. | ||
Request.put(Uri url, | ||
body, | ||
Request.put(url, body, | ||
{Encoding encoding, | ||
Map<String, String> headers, | ||
Map<String, Object> context}) | ||
|
@@ -110,8 +108,7 @@ class Request extends Message { | |
/// | ||
/// Extra [context] can be used to pass information between inner middleware | ||
/// and handlers. | ||
Request.patch(Uri url, | ||
body, | ||
Request.patch(url, body, | ||
{Encoding encoding, | ||
Map<String, String> headers, | ||
Map<String, Object> context}) | ||
|
@@ -125,10 +122,17 @@ class Request extends Message { | |
/// | ||
/// Extra [context] can be used to pass information between inner middleware | ||
/// and handlers. | ||
Request.delete(Uri url, | ||
Request.delete(url, | ||
{Map<String, String> headers, Map<String, Object> context}) | ||
: this('DELETE', url, headers: headers, context: context); | ||
|
||
Request._(this.method, this.url, | ||
body, | ||
Encoding encoding, | ||
Map<String, String> headers, | ||
Map<String, Object> context) | ||
: super(body, encoding: encoding, headers: headers, context: context); | ||
|
||
/// Creates a new [Request] by copying existing values and applying specified | ||
/// changes. | ||
/// | ||
|
@@ -147,10 +151,22 @@ class Request extends Message { | |
var updatedHeaders = updateMap(this.headers, headers); | ||
var updatedContext = updateMap(this.context, context); | ||
|
||
return new Request(this.method, this.url, | ||
body: body ?? getBody(this), | ||
encoding: this.encoding, | ||
headers: updatedHeaders, | ||
context: updatedContext); | ||
return new Request._( | ||
this.method, | ||
this.url, | ||
body ?? getBody(this), | ||
this.encoding, | ||
updatedHeaders, | ||
updatedContext); | ||
} | ||
} | ||
|
||
Uri _uri(url) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Either make this a static method of |
||
if (url is Uri) { | ||
return url; | ||
} else if (url is String) { | ||
return Uri.parse(url); | ||
} else { | ||
throw new ArgumentError.value(url, 'url', 'Not a Uri or String'); | ||
} | ||
} |
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.
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.
Document the acceptable types for
url
. You can probably just copy the docs from the top-level methods.