-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Get mime fallback #2340
Get mime fallback #2340
Conversation
Thanks for opening this pull request! 🎉 Please check out our contributing guidelines. If you need help or want to chat with us, join us on Discord https://gofiber.io/discord |
@derkan Some small errors showing up in the tests/lint |
@derkan Are the tests passing locally for you? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please check the failed tests
yes |
problem is with go.1.16. For the following code: package main
import (
"fmt"
"mime"
)
func main() {
fmt.Println("result:", mime.TypeByExtension(".text"))
}
And because of this, Test_Ctx_Accepts fails for go.1.16 at line: utils.AssertEqual(t, "json", c.Accepts("json", "text")) |
https://expressjs.com/en/5x/api.html#req.accepts we need a solution for this case |
@ReneWerner87 a wrapper function(for making variadic - array type for mime names) around mime.ParseMediaType(...) can be enough? Playground |
@gaby @leonklingele @efectn any ideas or opinions ? |
It's a nice feature to add. I'm confused as to why the tests dont' pass for go 1.16 though. May be worth making sure our unit-tests match the expected results as shown in https://expressjs.com/en/5x/api.html#req.accepts |
…http.static Note: I patched the mime-type code in gofiber's utils to support mjs but a better fix will hopefully be available once gofiber/fiber#2340 is merged in. For now every time I run `go mod vendor` I will have to update that file back to my patched version
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm! 🚀
@derkan Can you update your branch with the latest changes in master. Trying to see if tests will pass. |
…into get_mime_fallback
CI is passing now! |
It’s just flaky.
|
i have made a sync with the upstream, otherwise you don't see the real changes because of all the copies(144 files) of the changes from the masters |
Congrats on merging your first pull request! 🎉 We here at Fiber are proud of you! If you need help or want to chat with us, join us on Discord https://gofiber.io/discord |
Thank you all! 💯 |
Description
With current
filesystem
middleware, we don't let user to set custom content-type for a new extension when called from here. Becuse fiber's getMIME function uses statically defined mime types which cannot be changed.This is needed when serving SPA project from emdedded filesystem where custom contet-types are needed. (i.e.sveltekit *.mjs file)
Fixes:
Allows fallback to golang's mime package for content-type detection. Because, go's default mime package allows setting custom mime types.
Type of change
Please delete options that are not relevant.
Checklist: