We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 9b316a3 commit 43fb492Copy full SHA for 43fb492
modules/context/context.go
@@ -229,6 +229,23 @@ func (ctx *Context) notFoundInternal(title string, err error) {
229
}
230
231
232
+ // response simple meesage if Accept isn't text/html
233
+ reqTypes, has := ctx.Req.Header["Accept"]
234
+ if has && len(reqTypes) > 0 {
235
+ notHTML := true
236
+ for _, part := range reqTypes {
237
+ if strings.Contains(part, "text/html") {
238
+ notHTML = false
239
+ break
240
+ }
241
242
+
243
+ if notHTML {
244
+ ctx.PlainText(404, []byte("Not found.\n"))
245
+ return
246
247
248
249
ctx.Data["IsRepo"] = ctx.Repo.Repository != nil
250
ctx.Data["Title"] = "Page Not Found"
251
ctx.HTML(http.StatusNotFound, base.TplName("status/404"))
0 commit comments