-
Notifications
You must be signed in to change notification settings - Fork 163
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
Export mimetypes #127
Comments
Agreed. Happy to create a PR to that extent! |
I'm open for discussion on this. arg 1.
If I have to rename a mimetype, then I will use the old mimetype as an alias. if mime.Is("image/svg+xml") ... will continue to work the same. arg 2.
Ok, this would help with compile time errors, but I'd argue in general, one needs to pay attention to what he writes when coding. |
The challenge with the current approach is that from a developer perspective, I need to explicitly know the full type/subtype of the mimetype I want to reference, rather than just it's generalized name. With the exporting of these, it will muddy the namespace scope a bit, but will make finding the given mimetypes substantially faster. Additionally, instead of: mime, _ := mimetype.DetectFile(file)
if mime.Is("image/svg+xml") ... the code becomes: mime, _ := mimetype.DetectFile(file)
if mime == mimetype.SVG ... |
The alternative use-case that interests me more is something like: contentTypeHeader := resp.Header.Get("Content-Type")
mime := mimetype.Lookup(contentTypeHeader)
if mime == mimetype.SVG ... It's desirable to have in a library like this, since it is not going to be added to |
@gabriel-vasile - Is this something you're considering? If so, do you want anything else done on the PR? Thanks! |
As a developer using this library I would like to use these already defined mimetypes instead of matching on string literals so that if something changes I don't have to worry and I don't have to double check that I've written the right mimetype correctly.
Eg.
instead of
However this seems like something pretty obvious so if there is any reason this isn't already implemented please explain?
The text was updated successfully, but these errors were encountered: