Skip to content

Commit

Permalink
add HEAD support, close #10
Browse files Browse the repository at this point in the history
  • Loading branch information
codeskyblue committed Sep 21, 2016
1 parent 7a1831c commit 61758ec
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion httpstaticserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func NewHTTPStaticServer(root string) *HTTPStaticServer {
// TODO: /ipa/info
m.HandleFunc("/-/info/{path:.*}", s.hInfo)

m.HandleFunc("/{path:.*}", s.hIndex).Methods("GET")
m.HandleFunc("/{path:.*}", s.hIndex).Methods("GET", "HEAD")
m.HandleFunc("/{path:.*}", s.hUpload).Methods("POST")
m.HandleFunc("/{path:.*}", s.hDelete).Methods("DELETE")
return s
Expand All @@ -90,6 +90,9 @@ func (s *HTTPStaticServer) hIndex(w http.ResponseWriter, r *http.Request) {
relPath := filepath.Join(s.Root, path)

if r.FormValue("raw") == "false" || isDir(relPath) {
if r.Method == "HEAD" {
return
}
tmpl.ExecuteTemplate(w, "index", s)
} else {
if r.FormValue("download") == "true" {
Expand Down

0 comments on commit 61758ec

Please sign in to comment.