route: no session for routes without UI (#6066)

Not all routes need session, register session and CSRF middleware as global is a waste of resource, and creating a lot one-time off yet never used session records.
This commit is contained in:
ᴜɴᴋɴᴡᴏɴ
2020-04-05 06:36:08 +08:00
committed by GitHub
parent bae1d6ccd8
commit 07818d5fa5
10 changed files with 529 additions and 532 deletions

View File

@@ -5,7 +5,12 @@
package route
import (
"fmt"
"net/http"
"github.com/go-macaron/i18n"
"github.com/unknwon/paginater"
"gopkg.in/macaron.v1"
"gogs.io/gogs/internal/conf"
"gogs.io/gogs/internal/context"
@@ -157,7 +162,7 @@ func ExploreOrganizations(c *context.Context) {
})
}
func NotFound(c *context.Context) {
c.Data["Title"] = "Page Not Found"
c.NotFound()
func NotFound(c *macaron.Context, l i18n.Locale) {
c.Data["Title"] = l.Tr("status.page_not_found")
c.HTML(http.StatusNotFound, fmt.Sprintf("status/%d", http.StatusNotFound))
}