dart-lang / http_parser

A platform-independent Dart package for parsing and serializing HTTP formats.
https://pub.dev/packages/http_parser
BSD 3-Clause "New" or "Revised" License
38 stars 28 forks source link

Add an `isJson` getter to `MediaType` #52

Open kevmoo opened 2 years ago

kevmoo commented 2 years ago

It's so crazy common to want to check this – and it's not super straight-forward.

See

https://github.com/google/googleapis.dart/blob/ec7b27cf3895c92b75ef407e1c109a9f7eba3a72/discoveryapis_commons/lib/src/utils.dart#L10-L16

https://github.com/GoogleCloudPlatform/functions-framework-dart/blob/80da6491efbf2e58a2c3f4732a3a7f055fe5eb37/functions_framework/lib/src/json_request_utils.dart#L39