Merge "app/publisher: do not show all published nodes at root"

This commit is contained in:
Mathieu Lonjaret 2017-01-16 18:26:00 +00:00 committed by Gerrit Code Review
commit 7e7046db6d
1 changed files with 9 additions and 3 deletions

View File

@ -676,7 +676,7 @@ func (ph *publishHandler) NewRequest(w http.ResponseWriter, r *http.Request) (*p
ph: ph,
rw: w,
req: r,
suffix: suffix,
suffix: strings.TrimSuffix(suffix, "/"),
base: base,
subres: res,
rootpn: ph.rootNode,
@ -687,7 +687,13 @@ func (ph *publishHandler) NewRequest(w http.ResponseWriter, r *http.Request) (*p
func (pr *publishRequest) serveHTTP() {
if !pr.rootpn.Valid() {
pr.rw.WriteHeader(404)
http.NotFound(pr.rw, pr.req)
return
}
if pr.suffix == "" {
// Do not show everything at the root.
http.NotFound(pr.rw, pr.req)
return
}
@ -699,7 +705,7 @@ func (pr *publishRequest) serveHTTP() {
if err := pr.findSubject(); err != nil {
if err == os.ErrNotExist {
pr.rw.WriteHeader(404)
http.NotFound(pr.rw, pr.req)
return
}
logf("Error looking up %s/%q: %v", pr.rootpn, pr.suffix, err)