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