Return 0 when there is no error (Golang)

This commit is contained in:
Henrique Dias
2017-06-28 19:06:08 +01:00
parent 8a1a160197
commit b214fdd0eb
8 changed files with 108 additions and 135 deletions

View File

@@ -3,7 +3,6 @@ package filemanager
import (
"net/http"
"strconv"
"strings"
)
func serveDefault(c *requestContext, w http.ResponseWriter, r *http.Request) (int, error) {
@@ -53,13 +52,7 @@ func serveDefault(c *requestContext, w http.ResponseWriter, r *http.Request) (in
}
}
// If the request accepts JSON, we send the file information.
if strings.Contains(r.Header.Get("Accept"), "application/json") {
c.pg.Data = c.fi
return c.pg.PrintJSON(w)
}
return c.pg.PrintHTML(w, c.fm.templates)
return c.pg.Render(c, w, r)
}
// serveListing presents the user with a listage of a directory folder.
@@ -98,12 +91,7 @@ func serveListing(c *requestContext, w http.ResponseWriter, r *http.Request) (in
listing.Display = displayMode(w, r, cookieScope)
c.pg.Data = listing
// If it's a JSON request, print only the items... in JSON! (such a surprise -_-)
if strings.Contains(r.Header.Get("Accept"), "application/json") {
return c.pg.PrintJSON(w)
}
return c.pg.PrintHTML(w, c.fm.templates)
return c.pg.Render(c, w, r)
}
// displayMode obtaisn the display mode from URL, or from the