Skip to content

Commit

Permalink
Merge pull request #144 from jeyb/static_for_get_fix
Browse files Browse the repository at this point in the history
Fixes regression introduced by /pull/143
  • Loading branch information
codegangsta committed Jan 2, 2014
2 parents 9d00143 + 69ed4a9 commit 50f2d3f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
7 changes: 1 addition & 6 deletions static.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,9 @@ import (
func Static(directory string) Handler {
dir := http.Dir(directory)
return func(res http.ResponseWriter, req *http.Request, log *log.Logger) {
if req.Method != "GET" {
res.WriteHeader(http.StatusNotFound)
return
}

file := req.URL.Path
f, err := dir.Open(file)
if err != nil {
if err != nil || req.Method != "GET" {
// discard the error?
return
}
Expand Down
2 changes: 2 additions & 0 deletions static_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ func Test_Static_As_Post(t *testing.T) {
response := httptest.NewRecorder()

m := New()
r := NewRouter()

m.Use(Static("."))
m.Action(r.Handle)

req, err := http.NewRequest("POST", "http://localhost:3000/martini.go", nil)
if err != nil {
Expand Down

0 comments on commit 50f2d3f

Please sign in to comment.