Added a 404 path for assets that doesn't render the full template

This commit is contained in:
Asaf Gartner 2021-05-04 16:35:30 +03:00
parent 94bd05751e
commit 0da3a1ffb9
1 changed files with 13 additions and 8 deletions

View File

@ -166,6 +166,10 @@ func ProjectCSS(c *RequestContext) ResponseData {
} }
func FourOhFour(c *RequestContext) ResponseData { func FourOhFour(c *RequestContext) ResponseData {
var res ResponseData
res.StatusCode = http.StatusNotFound
if c.Req.Header["Accept"] != nil && strings.Contains(c.Req.Header["Accept"][0], "text/html") {
templateData := struct { templateData := struct {
templates.BaseData templates.BaseData
Wanted string Wanted string
@ -173,9 +177,10 @@ func FourOhFour(c *RequestContext) ResponseData {
BaseData: getBaseData(c), BaseData: getBaseData(c),
Wanted: c.FullUrl(), Wanted: c.FullUrl(),
} }
var res ResponseData
res.StatusCode = http.StatusNotFound
res.WriteTemplate("404.html", templateData, c.Perf) res.WriteTemplate("404.html", templateData, c.Perf)
} else {
res.Write([]byte("Not Found"))
}
return res return res
} }