-
Notifications
You must be signed in to change notification settings - Fork 26
feat: Refactor Response class and add new initialization methods #28
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
base: main
Are you sure you want to change the base?
Conversation
- Add default response status and status text in the `Response` constructors - Add `Response.jsify` method for initializing `Response` with a JS object as body - Separate `Response.json` method from `Response.jsify` for initializing `Response` with a JSON-encodable object as body - Add documentation for main the constructors of `Response`
|
@gaetschwartz thanks for this - what's the use case for the |
|
Well, as |
|
I'm not really familiar with the project, but it looks alright at a quick glance. I'd still consider this a breaking change (since the "json" constructor changes). |
Co-authored-by: Remi Rousselet <[email protected]>
Changes
ResponseconstructorsResponse.jsifymethod for initializingResponsewith a JS object as bodyResponse.jsonmethod fromResponse.jsifyfor initializingResponsewith a JSON-encodable object as bodyResponseMotivation
jsifyis subject to minification and has somewhat bad performance. When usingdart compilewith minification enabled, the response json gets minified (after a certain depth AFAIK). It should not be the case. The newResponse.jsonbehaves simlarly from the previous implementation except that it doesn't minify as it usesjson.encode. Renamed the previous implementation toResponse.jsifyas it could still be useful for some cases.