Skip to content

Remove BakedFile#mime_type#22

Merged
straight-shoota merged 1 commit into
schovi:masterfrom
straight-shoota:jm/remove-mime-type
Feb 11, 2019
Merged

Remove BakedFile#mime_type#22
straight-shoota merged 1 commit into
schovi:masterfrom
straight-shoota:jm/remove-mime-type

Conversation

@straight-shoota
Copy link
Copy Markdown
Collaborator

Closes #17

Comment thread src/loader/loader.cr
@straight-shoota
Copy link
Copy Markdown
Collaborator Author

MIME type resolution should not need to be implemented multiple times but in a generic, reusable way. That's why this shouldn't be included in this shard.

There is an issue to bring a MIME registry to Crystal's stdlib and I've been working on that, but it's not ready yet. There are some shards available with a MIME registry, they can be used to resolve the MIME type at runtime. Depending on a system command at compile time is not a great idea because this would mean you need a properly configured registry on the build system if you don't want to face MIME type issues at runtime. That's just impractical. Shelling out to use a system tool is also not optimal, this should also be handled inside crystal.

@schovi
Copy link
Copy Markdown
Owner

schovi commented Feb 28, 2018

@straight-shoota
Thanks for an explanation. Can you add an example of working shard to readme? Or can we wait with this PR until it will be available directly in stdlib?

@straight-shoota
Copy link
Copy Markdown
Collaborator Author

Let's wait for crystal-lang/crystal#5765. Should hopefully go in the next release.

@straight-shoota straight-shoota merged commit 4fb8df7 into schovi:master Feb 11, 2019
@straight-shoota straight-shoota deleted the jm/remove-mime-type branch February 11, 2019 14:38
@straight-shoota
Copy link
Copy Markdown
Collaborator Author

The MIME registry was finally released in Crystal 0.27.1, so this PR can now be merged.

Instead of baked_file.mime_type, the mime type can now be queried as MIME.from_filename(baked_file.path).
See stdlib API docs for more details.

@schovi
Copy link
Copy Markdown
Owner

schovi commented Feb 11, 2019

@straight-shoota awesome 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants