@@ -25,11 +25,11 @@ import (
2525 "code.gitea.io/gitea/modules/base"
2626 mc "code.gitea.io/gitea/modules/cache"
2727 "code.gitea.io/gitea/modules/log"
28- "code.gitea.io/gitea/modules/middlewares"
2928 "code.gitea.io/gitea/modules/setting"
3029 "code.gitea.io/gitea/modules/templates"
3130 "code.gitea.io/gitea/modules/translation"
3231 "code.gitea.io/gitea/modules/util"
32+ "code.gitea.io/gitea/modules/web/middleware"
3333
3434 "gitea.com/go-chi/cache"
3535 "gitea.com/go-chi/session"
@@ -55,7 +55,7 @@ type Context struct {
5555 translation.Locale
5656 Cache cache.Cache
5757 csrf CSRF
58- Flash * middlewares .Flash
58+ Flash * middleware .Flash
5959 Session session.Store
6060
6161 Link string // current request URL
@@ -197,7 +197,7 @@ func (ctx *Context) HTMLString(name string, data interface{}) (string, error) {
197197// RenderWithErr used for page has form validation but need to prompt error to users.
198198func (ctx * Context ) RenderWithErr (msg string , tpl base.TplName , form interface {}) {
199199 if form != nil {
200- middlewares .AssignForm (form , ctx .Data )
200+ middleware .AssignForm (form , ctx .Data )
201201 }
202202 ctx .Flash .ErrorMsg = msg
203203 ctx .Data ["Flash" ] = ctx .Flash
@@ -375,12 +375,12 @@ func (ctx *Context) Redirect(location string, status ...int) {
375375
376376// SetCookie set cookies to web browser
377377func (ctx * Context ) SetCookie (name string , value string , others ... interface {}) {
378- middlewares .SetCookie (ctx .Resp , name , value , others ... )
378+ middleware .SetCookie (ctx .Resp , name , value , others ... )
379379}
380380
381381// GetCookie returns given cookie value from request header.
382382func (ctx * Context ) GetCookie (name string ) string {
383- return middlewares .GetCookie (ctx .Req , name )
383+ return middleware .GetCookie (ctx .Req , name )
384384}
385385
386386// GetSuperSecureCookie returns given cookie value from request header with secret string.
@@ -505,7 +505,7 @@ func Contexter() func(next http.Handler) http.Handler {
505505
506506 return func (next http.Handler ) http.Handler {
507507 return http .HandlerFunc (func (resp http.ResponseWriter , req * http.Request ) {
508- var locale = middlewares .Locale (resp , req )
508+ var locale = middleware .Locale (resp , req )
509509 var startTime = time .Now ()
510510 var link = setting .AppSubURL + strings .TrimSuffix (req .URL .EscapedPath (), "/" )
511511 var ctx = Context {
@@ -536,7 +536,7 @@ func Contexter() func(next http.Handler) http.Handler {
536536 flashCookie := ctx .GetCookie ("macaron_flash" )
537537 vals , _ := url .ParseQuery (flashCookie )
538538 if len (vals ) > 0 {
539- f := & middlewares .Flash {
539+ f := & middleware .Flash {
540540 DataStore : & ctx ,
541541 Values : vals ,
542542 ErrorMsg : vals .Get ("error" ),
@@ -547,7 +547,7 @@ func Contexter() func(next http.Handler) http.Handler {
547547 ctx .Data ["Flash" ] = f
548548 }
549549
550- f := & middlewares .Flash {
550+ f := & middleware .Flash {
551551 DataStore : & ctx ,
552552 Values : url.Values {},
553553 ErrorMsg : "" ,
@@ -557,22 +557,22 @@ func Contexter() func(next http.Handler) http.Handler {
557557 }
558558 ctx .Resp .Before (func (resp ResponseWriter ) {
559559 if flash := f .Encode (); len (flash ) > 0 {
560- middlewares .SetCookie (resp , "macaron_flash" , flash , 0 ,
560+ middleware .SetCookie (resp , "macaron_flash" , flash , 0 ,
561561 setting .SessionConfig .CookiePath ,
562- middlewares .Domain (setting .SessionConfig .Domain ),
563- middlewares .HTTPOnly (true ),
564- middlewares .Secure (setting .SessionConfig .Secure ),
562+ middleware .Domain (setting .SessionConfig .Domain ),
563+ middleware .HTTPOnly (true ),
564+ middleware .Secure (setting .SessionConfig .Secure ),
565565 //middlewares.SameSite(opt.SameSite), FIXME: we need a samesite config
566566 )
567567 return
568568 }
569569
570570 ctx .SetCookie ("macaron_flash" , "" , - 1 ,
571571 setting .SessionConfig .CookiePath ,
572- middlewares .Domain (setting .SessionConfig .Domain ),
573- middlewares .HTTPOnly (true ),
574- middlewares .Secure (setting .SessionConfig .Secure ),
575- //middlewares .SameSite(), FIXME: we need a samesite config
572+ middleware .Domain (setting .SessionConfig .Domain ),
573+ middleware .HTTPOnly (true ),
574+ middleware .Secure (setting .SessionConfig .Secure ),
575+ //middleware .SameSite(), FIXME: we need a samesite config
576576 )
577577 })
578578
0 commit comments