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

Consider making MediaType a compile-time constant #84

Open pattobrien opened 7 months ago

pattobrien commented 7 months ago

I'm working on a code-gen package to improve the UX of creating backend apps. One of the primary use cases is to register acceptable MediaTypes for a given endpoint, and map it to a body parser. Since MediaType is not a compile-time constant, I'm unable to achieve the following:

@BodyParser({MediaType.multipartForm})
UserDto userFromForm(List<int> data) => _$UserFromForm

Would we be willing to reconsider looking into this issue or accept a PR?

My workaround for the time being will be to create my own MediaType class, but I'd ideally like to not fragment from popular packages like this one.