Return 0 when there is no error (Golang)
Former-commit-id: e7c4248761e085dd763c7d2fb93e3b364d46cc1f [formerly 59e9b4ed8b656dc61119e7c758fb47ee30c36ad6] [formerly 4e5e9413d14ec8ee0a3a2abbee7f607b15910315 [formerly b214fdd0ebe2bb564cbe64a12dbac725bc4d3f66]] Former-commit-id: 1dc992ecd0b0169e66f854083554ae825ffa3ddf [formerly 65f85346c9875abcaaa0fa97fa8689ebea774f37] Former-commit-id: aac3de2cf26430814b9db7073b42f5791ff2a566
This commit is contained in:
16
serve.go
16
serve.go
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user