-
Notifications
You must be signed in to change notification settings - Fork 405
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
MimeDB.scala
which is the mapping of file extension
to Media Type
should be auto-generated.
#934
Comments
MimeDB.scala
which is the mapping of file extension
to Media Type
. It should be auto-generated.MimeDB.scala
which is the mapping of file extension
to Media Type
should be auto-generated.
/bounty $500 For a clean solution that requires no third-party dependencies and is easy to update. |
|
/attempt #934
|
@kitlangton: Reminder that in 7 days the bounty will become up for grabs, so please submit a pull request before then 🙏 |
@kitlangton just wanted to check-in with you if you're still working or planning to work on this issue. I'm also happy to collaborate on it if you like |
💡 @kitlangton submitted a pull request that claims the bounty. You can visit your bounty board to reward. |
🎉🎈 @kitlangton has been awarded $500! 🎈🎊 |
What is not easy to do right now?
#889 introduces a file -
MimeDB.scala
which is the mapping offile extension
toMedia Type
. It should be auto-generated.If a new
Media-Type
is added to masterMime db
at https://cdn.jsdelivr.net/gh/jshttp/mime-db@master/db.json, it will have to be added manually to thezio-http
codebase.Describe the solution you'd like
There should be a way to either (1) automatically generate 'MimeDB.scala' from https://cdn.jsdelivr.net/gh/jshttp/mime-db@master/db.json` or (2) detection and addition of
Content-Type
header should be possible by directly using the mappings at https://cdn.jsdelivr.net/gh/jshttp/mime-db@master/db.jsonWhy is it important?
Future maintenance overhead will be high if this is not done.
Additional context
A few options for generating
MimeDB.scala
are -As I understand, there are a few different options for auto-generating
MimeDB.scala
Generating code using string templates (Twirl).
Pros : This seems to have the easiest learning curve of all the approaches.
Twirl works very well with scala. The syntax is
scala-ish
Code is easy to read and understand.
Cons : Can produce code that doesn't compile.
Generating code from an abstract syntax tree (treehugger).
Pros : Uncompilable code cannot be generated.
Uses scala syntax.
Cons : Steep learning curve. Will take me some time to do this.
Not much IDE support.
Code looks complex, reader might take some time to understand what is happening.
Building an abstract syntax tree and sending it directly to the compiler (Scala macros).
Pros : Directly passes bytecode of AST to next phase of compilation without generating
.scala
fileSyntactically invalid code will not be generated.
Cons : Steep learning curve. Will take me some time to complete this.
Not much IDE support.
Code can be complex. Reader needs to know macros to understand what is happening.
Skip generating case classes entirely, by directly parsing json into a Map.
Concern : There’s a 4kb limit on the size of a map in jvm afaik, so the Map will have to be split. Also, handling all edge-cases
might get complicated.
The text was updated successfully, but these errors were encountered: