Skip to content

Commit

Permalink
mod: bump github.com/stretchr/testify from 1.9.0 to 1.10.0 (#56)
Browse files Browse the repository at this point in the history
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Joe Chen <jc@unknwon.io>
  • Loading branch information
dependabot[bot] and unknwon authored Nov 26, 2024
1 parent 173ffd4 commit c565349
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 54 deletions.
28 changes: 0 additions & 28 deletions .github/workflows/lsif.yml

This file was deleted.

6 changes: 2 additions & 4 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,16 @@ linters-settings:

linters:
enable:
- deadcode
- unused
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- structcheck
- typecheck
- unused
- varcheck
- nakedret
- gofmt
- rowserrcheck
- unconvert
- goimports
- unparam
34 changes: 15 additions & 19 deletions csrf.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,32 +160,28 @@ func Csrfer(opts ...Options) flamego.Handler {
opt = opts[0]
}

parseOptions := func(opts Options) Options {
if opt.Secret == "" {
opt.Secret = string(randomBytes(10))
}
if opt.Secret == "" {
opt.Secret = string(randomBytes(10))
}

if opt.Header == "" {
opt.Header = defaultHeader
}
if opt.Header == "" {
opt.Header = defaultHeader
}

if opt.Form == "" {
opt.Form = defaultForm
}
if opt.Form == "" {
opt.Form = defaultForm
}

if opt.SessionKey == "" {
opt.SessionKey = defaultSessionKey
}
if opt.SessionKey == "" {
opt.SessionKey = defaultSessionKey
}

if opt.ErrorFunc == nil {
opt.ErrorFunc = func(w http.ResponseWriter) {
http.Error(w, "Bad Request: invalid CSRF token", http.StatusBadRequest)
}
if opt.ErrorFunc == nil {
opt.ErrorFunc = func(w http.ResponseWriter) {
http.Error(w, "Bad Request: invalid CSRF token", http.StatusBadRequest)
}
return opt
}

opt = parseOptions(opt)
return csrfInvoker(func(c flamego.Context, s session.Session) {
x := &csrf{
secret: opt.Secret,
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.18
require (
github.com/flamego/flamego v1.9.4
github.com/flamego/session v1.6.3
github.com/stretchr/testify v1.9.0
github.com/stretchr/testify v1.10.0
)

require (
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU=
Expand Down

0 comments on commit c565349

Please sign in to comment.