-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Improve filesystem support #2064
Conversation
well well, I forgot already that |
I'd suggest we tag this PR as v5 and merge on the v5 branch where Go < 1.16 is dropped, so we can use fs.FS directly from Go. What do you think @aldas ? |
There is not point tag it as I can make it work with Go 1.16+ versions with build constraints. I would create additional struct to be embedded into Add it to Lines 68 to 70 in 296c313
and create version specific implementations in that versioned file // +build go1.16
type versioned struct {
Filesystem fs.FS
}
// ... methods requiring fs.FS interface // +build !go1.16
type versioned struct {} |
If it is not too much effort, great. Than we can merge it for v4.6. Lovely! |
…hods: echo.FileFS, echo.StaticFS, group.FileFS, group.StaticFS. Following methods will use echo.Filesystem to server files: echo.File, echo.Static, group.File, group.Static, Context.File
bf0adea
to
f182524
Compare
Codecov Report
@@ Coverage Diff @@
## master #2064 +/- ##
==========================================
+ Coverage 91.57% 91.76% +0.18%
==========================================
Files 33 36 +3
Lines 2921 2962 +41
==========================================
+ Hits 2675 2718 +43
+ Misses 157 156 -1
+ Partials 89 88 -1
Continue to review full report at Codecov.
|
Ok, this should be done now. Added some tweaks for easier usage with Please review @lammel |
bump @lammel |
Bump noted ;-) Checking now... |
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.
Reviewed all files, LGTM. Very nice stuff to support Go 1.16 too.
I think the behavior of before e.Static("/static", staticDir) seems not to work the way it did in 4.6.x, as I do get HTTP 404 errors instead of the files above. after e.StaticFS("/static", os.DirFS(staticDir)) |
@jxsl13 are you using relative paths as And let me clarify. a) This line |
@aldas sorry for the late reply I am constructing an absolute path from os.Getwd + some subdirectories. So |
@jxsl13 please try |
@aldas it does work again. |
State in 4.7.1: |
nice. for history sake: |
Improve filesystem support. Relates to #2059 I have taken some code from
v5
and made itv4
compatibleUsable if you have Go 1.16+, older Go versions will use old implementation
echo.New()
emulates how previouslyos.Open
workedNote:
embed.FS
embedds files with full paths that include that same embedded directory name as prefix. In that case you can use helper function to create sub fs with that prefixecho.MustSubFS(embedded, rootDirectory)
. That "root prefix" was not added to the method signature as there could befs.FS
implementations that do not act that way.Example with
embed.FS
: