-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Fix Static files route not working #1654
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
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1654 +/- ##
==========================================
- Coverage 85.28% 84.17% -1.12%
==========================================
Files 28 28
Lines 2216 1902 -314
==========================================
- Hits 1890 1601 -289
+ Misses 212 189 -23
+ Partials 114 112 -2
Continue to review full report at Codecov.
|
@@ -496,6 +496,7 @@ func (common) static(prefix, root string, get func(string, HandlerFunc, ...Middl | |||
} | |||
return c.File(name) | |||
} | |||
get(prefix, h) |
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
Maybe you can add a new unit test, to avoid future regressions
func TestEchoStaticRedirectIndex(t *testing.T) {
assert := assert.New(t)
e := New()
// HandlerFunc
e.Static("/static", "_fixture")
errCh := make(chan error)
go func() {
errCh <- e.Start("127.0.0.1:1323")
}()
time.Sleep(200 * time.Millisecond)
if resp, err := http.Get("http://127.0.0.1:1323/static"); err == nil {
defer resp.Body.Close()
assert.Equal(http.StatusOK, resp.StatusCode)
if body, err := ioutil.ReadAll(resp.Body); err == nil {
assert.Equal(true, strings.HasPrefix(string(body), "<!doctype html>"))
} else {
assert.Fail(err.Error())
}
} else {
assert.Fail(err.Error())
}
if err := e.Close(); err != nil {
t.Fatal(err)
}
}
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.
yes, I'll fix the Directory Redirect test case and add a TestEchoStaticRedirectIndex func for strengthening.
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.
I'm not an expert on Codecov, but when I updated my PRs with the latest changes on master, it pass. Maybe it was in a weird state when you created your PR in the first place, and the comparison with the coverage on master is not quite correct. My suggestion is to update this PR with the latest master changes.
closing,move to #1671 |
just opened another PR, pls have a check |
fix 404 error when using Static files route
Echo.Static()
related issue