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

Automatically guess content-type if one is not provided #5

Open
MasterOdin opened this issue Dec 3, 2020 · 0 comments · May be fixed by #6
Open

Automatically guess content-type if one is not provided #5

MasterOdin opened this issue Dec 3, 2020 · 0 comments · May be fixed by #6
Labels
enhancement New feature or request

Comments

@MasterOdin
Copy link
Member

Right now, if no content-type is not provided, the receiver will just assume that it's receiving a Buffer. This limits the usefulness of the automatic parsing when dealing with legacy code as the receiver then basically always has to specify {contentType: 'application/json'}.

Instead of this manual step for unknown content types, it would be better for @cisl/io to try and guess the content type if it's not provided by doing something like:

try {
  content = content.toString();
  content = JSON.parse(content);
}
catch {
  // do nothing
}

return content;
@MasterOdin MasterOdin added the enhancement New feature or request label Dec 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant