mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-25 11:22:16 +00:00
Allow disable RSS/Atom feed (#21622)
This patch provide a mechanism to disable RSS/Atom feed. Signed-off-by: Xinyu Zhou <i@sourcehut.net> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: 6543 <6543@obermui.de>
This commit is contained in:
parent
9380bb6d0c
commit
b4802b9b2e
10 changed files with 40 additions and 15 deletions
|
@ -310,6 +310,13 @@ func RegisterRoutes(m *web.Route) {
|
|||
}
|
||||
}
|
||||
|
||||
feedEnabled := func(ctx *context.Context) {
|
||||
if !setting.EnableFeed {
|
||||
ctx.Error(http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME: not all routes need go through same middleware.
|
||||
// Especially some AJAX requests, we can reduce middleware number to improve performance.
|
||||
// Routers.
|
||||
|
@ -633,9 +640,11 @@ func RegisterRoutes(m *web.Route) {
|
|||
m.Get(".png", func(ctx *context.Context) { ctx.Error(http.StatusNotFound) })
|
||||
m.Get(".keys", user.ShowSSHKeys)
|
||||
m.Get(".gpg", user.ShowGPGKeys)
|
||||
m.Get(".rss", feed.ShowUserFeedRSS)
|
||||
m.Get(".atom", feed.ShowUserFeedAtom)
|
||||
m.Get(".rss", feedEnabled, feed.ShowUserFeedRSS)
|
||||
m.Get(".atom", feedEnabled, feed.ShowUserFeedAtom)
|
||||
m.Get("", user.Profile)
|
||||
}, func(ctx *context.Context) {
|
||||
ctx.Data["EnableFeed"] = setting.EnableFeed
|
||||
}, context_service.UserAssignmentWeb())
|
||||
m.Get("/attachments/{uuid}", repo.GetAttachment)
|
||||
}, ignSignIn)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue