Skip to content

Commit 9b98220

Browse files
committed
Fix middleware.Wrap struct
1 parent e2712a6 commit 9b98220

File tree

2 files changed

+1
-5
lines changed

2 files changed

+1
-5
lines changed

middleware/wrap.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,21 @@ import (
99
type Wrap struct {
1010
logger *logrus.Entry
1111
list []func(http.Handler) http.Handler
12-
len int8
1312
}
1413

1514
func NewWrap(logger *logrus.Logger) *Wrap {
1615
return &Wrap{
1716
logger: logger.WithField("component", "middlewareWrap"),
1817
list: make([]func(http.Handler) http.Handler, 0),
19-
len: 0,
2018
}
2119
}
2220

2321
func (s *Wrap) Add(middleware func(http.Handler) http.Handler) {
2422
s.list = append(s.list, middleware)
25-
s.len++
2623
}
2724

2825
func (s *Wrap) Do(handler http.Handler) http.Handler {
29-
for i := int8(0); i < s.len; i++ {
26+
for i := 0; i < len(s.list); i++ {
3027
handler = s.list[i](handler)
3128
}
3229
return http.HandlerFunc(func(resp http.ResponseWriter, req *http.Request) {

middleware/wrap_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ func TestWrap_Add(t *testing.T) {
1515
wrap.Add(func(handler http.Handler) http.Handler { return handler })
1616
}
1717
a.Len(wrap.list, eLen)
18-
a.Equal(wrap.len, int8(eLen))
1918
}
2019

2120
func TestWrap_Do(t *testing.T) {

0 commit comments

Comments
 (0)