Skip to content

Commit f645368

Browse files
committed
Use gitea.com/go-chi/binding
1 parent 29901cd commit f645368

File tree

120 files changed

+326
-11921
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

120 files changed

+326
-11921
lines changed

cmd/web.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ func runWeb(ctx *cli.Context) error {
134134
}
135135
}
136136
c := routes.NewChi()
137-
c.Mount("/", routers.InstallRoutes())
137+
c.Mount("/", routes.InstallRoutes())
138138
err := listen(c, false)
139139
select {
140140
case <-graceful.GetManager().IsShutdown():

go.mod

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ go 1.14
55
require (
66
code.gitea.io/gitea-vet v0.2.1
77
code.gitea.io/sdk/gitea v0.13.1
8+
gitea.com/go-chi/binding v0.0.0-20201220025549-f1056649c959
89
gitea.com/go-chi/session v0.0.0-20201218134809-7209fa084f27
910
gitea.com/lunny/levelqueue v0.3.0
1011
gitea.com/macaron/binding v0.0.0-20190822013154-a5f53841ed2b
@@ -21,7 +22,6 @@ require (
2122
github.com/PuerkitoBio/goquery v1.5.1
2223
github.com/RoaringBitmap/roaring v0.5.5 // indirect
2324
github.com/alecthomas/chroma v0.8.2
24-
github.com/alexedwards/scs/v2 v2.4.0
2525
github.com/andybalholm/brotli v1.0.1 // indirect
2626
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be // indirect
2727
github.com/blevesearch/bleve v1.0.14
@@ -89,7 +89,6 @@ require (
8989
github.com/sergi/go-diff v1.1.0
9090
github.com/shurcooL/httpfs v0.0.0-20190707220628-8d4bc4ba7749 // indirect
9191
github.com/shurcooL/vfsgen v0.0.0-20200824052919-0d455de96546
92-
github.com/smartystreets/goconvey v1.6.4
9392
github.com/spf13/viper v1.7.1 // indirect
9493
github.com/ssor/bom v0.0.0-20170718123548-6386211fdfcf // indirect
9594
github.com/stretchr/testify v1.6.1

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ code.gitea.io/gitea-vet v0.2.1/go.mod h1:zcNbT/aJEmivCAhfmkHOlT645KNOf9W2KnkLgFj
4040
code.gitea.io/sdk/gitea v0.13.1 h1:Y7bpH2iO6Q0KhhMJfjP/LZ0AmiYITeRQlCD8b0oYqhk=
4141
code.gitea.io/sdk/gitea v0.13.1/go.mod h1:z3uwDV/b9Ls47NGukYM9XhnHtqPh/J+t40lsUrR6JDY=
4242
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
43+
gitea.com/go-chi/binding v0.0.0-20201220025549-f1056649c959 h1:xcFbqqw8JUPTivvrwgDl5X1Chiby0gzASqbY5LmcOZ0=
44+
gitea.com/go-chi/binding v0.0.0-20201220025549-f1056649c959/go.mod h1:2F9XqNn+FUSSG6yXlEF/KRQk9Rf99eEqJkGBcrp6APM=
4345
gitea.com/go-chi/session v0.0.0-20201218134809-7209fa084f27 h1:cdb1OTNXGLwQ55gg+9tIPWufdsnrHWcIq8Qs+j/E8JU=
4446
gitea.com/go-chi/session v0.0.0-20201218134809-7209fa084f27/go.mod h1:Ozg8IchVNb/Udg+ui39iHRYqVHSvf3C99ixdpLR8Vu0=
4547
gitea.com/lunny/levelqueue v0.3.0 h1:MHn1GuSZkxvVEDMyAPqlc7A3cOW+q8RcGhRgH/xtm6I=
@@ -128,8 +130,6 @@ github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuy
128130
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
129131
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
130132
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho=
131-
github.com/alexedwards/scs/v2 v2.4.0 h1:XfnMamKnvp1muJVNr1WzikQTclopsBXWZtzz0NBjOK0=
132-
github.com/alexedwards/scs/v2 v2.4.0/go.mod h1:ToaROZxyKukJKT/xLcVQAChi5k6+Pn1Gvmdl7h3RRj8=
133133
github.com/andybalholm/brotli v1.0.0/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y=
134134
github.com/andybalholm/brotli v1.0.1 h1:KqhlKozYbRtJvsPrrEeXcO+N2l6NYT5A2QAFmSULpEc=
135135
github.com/andybalholm/brotli v1.0.1/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y=

modules/context/default.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@
55
package context
66

77
import (
8+
"context"
89
"net/http"
910

1011
"code.gitea.io/gitea/modules/auth"
11-
"code.gitea.io/gitea/modules/middlewares/binding"
1212
"code.gitea.io/gitea/modules/translation"
1313

14+
"gitea.com/go-chi/binding"
1415
"gitea.com/go-chi/session"
1516
"github.com/unrolled/render"
1617
)
@@ -98,3 +99,17 @@ func (ctx *DefaultContext) Flash(tp, v string) {
9899
ctx.Data[tp] = v
99100
ctx.Data["Flash"] = ctx.flash
100101
}
102+
103+
var (
104+
defaultContextKey interface{} = "default_context"
105+
)
106+
107+
// WithDefaultContext set up install context in request
108+
func WithDefaultContext(req *http.Request, ctx *DefaultContext) *http.Request {
109+
return req.WithContext(context.WithValue(req.Context(), defaultContextKey, ctx))
110+
}
111+
112+
// GetDefaultContext retrieves install context from request
113+
func GetDefaultContext(req *http.Request) *DefaultContext {
114+
return req.Context().Value(defaultContextKey).(*DefaultContext)
115+
}

modules/context/install.go

Lines changed: 0 additions & 27 deletions
This file was deleted.

modules/forms/forms.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ import (
88
"reflect"
99
"strings"
1010

11-
"code.gitea.io/gitea/modules/middlewares/binding"
1211
"code.gitea.io/gitea/modules/translation"
1312
"code.gitea.io/gitea/modules/validation"
1413

14+
"gitea.com/go-chi/binding"
1515
"github.com/unknwon/com"
1616
)
1717

modules/forms/install.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ import (
99
"net/http"
1010

1111
"code.gitea.io/gitea/modules/context"
12-
"code.gitea.io/gitea/modules/middlewares/binding"
12+
13+
"gitea.com/go-chi/binding"
1314
)
1415

1516
// InstallForm form for installation page
@@ -63,6 +64,6 @@ type InstallForm struct {
6364

6465
// Validate validates the fields
6566
func (f *InstallForm) Validate(req *http.Request, errs binding.Errors) binding.Errors {
66-
ctx := context.GetInstallContext(req)
67+
ctx := context.GetDefaultContext(req)
6768
return validate(errs, ctx.Data, f, ctx.Locale)
6869
}

modules/middlewares/binding/bind_test.go

Lines changed: 0 additions & 57 deletions
This file was deleted.

modules/middlewares/binding/common_test.go

Lines changed: 0 additions & 127 deletions
This file was deleted.

0 commit comments

Comments
 (0)