mirror of
https://github.com/osmarks/mycorrhiza.git
synced 2024-12-11 21:10:26 +00:00
Sending a 404 status if there is no content on the page
Probably a hack. I'm not sure how it should be done normally, but I have no other idea how to do it.
This commit is contained in:
parent
df9ee15a7f
commit
416c606e6d
@ -112,10 +112,19 @@ func handlerHypha(w http.ResponseWriter, rq *http.Request) {
|
|||||||
contents = views.AttachmentHTML(h) + contents
|
contents = views.AttachmentHTML(h) + contents
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
util.HTTP200Page(w,
|
if contents == "" {
|
||||||
views.BaseHTML(
|
util.HTTP404Page(w,
|
||||||
util.BeautifulName(hyphaName),
|
views.BaseHTML(
|
||||||
views.HyphaHTML(rq, h, contents),
|
util.BeautifulName(hyphaName),
|
||||||
u,
|
views.HyphaHTML(rq, h, contents),
|
||||||
openGraph))
|
u,
|
||||||
|
openGraph))
|
||||||
|
} else {
|
||||||
|
util.HTTP200Page(w,
|
||||||
|
views.BaseHTML(
|
||||||
|
util.BeautifulName(hyphaName),
|
||||||
|
views.HyphaHTML(rq, h, contents),
|
||||||
|
u,
|
||||||
|
openGraph))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,6 +53,13 @@ func ShorterPath(path string) string {
|
|||||||
return path
|
return path
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// HTTP404Page writes a 404 error in the status, needed when no content is found on the page.
|
||||||
|
func HTTP404Page(w http.ResponseWriter, page string) {
|
||||||
|
w.Header().Set("Content-Type", "text/html;charset=utf-8")
|
||||||
|
w.WriteHeader(http.StatusNotFound)
|
||||||
|
w.Write([]byte(page))
|
||||||
|
}
|
||||||
|
|
||||||
// HTTP200Page wraps some frequently used things for successful 200 responses.
|
// HTTP200Page wraps some frequently used things for successful 200 responses.
|
||||||
func HTTP200Page(w http.ResponseWriter, page string) {
|
func HTTP200Page(w http.ResponseWriter, page string) {
|
||||||
w.Header().Set("Content-Type", "text/html;charset=utf-8")
|
w.Header().Set("Content-Type", "text/html;charset=utf-8")
|
||||||
|
Loading…
Reference in New Issue
Block a user