File tree 5 files changed +11
-23
lines changed
5 files changed +11
-23
lines changed Original file line number Diff line number Diff line change @@ -101,10 +101,8 @@ type ValueBinder struct {
101
101
// QueryParamsBinder creates query parameter value binder
102
102
func QueryParamsBinder (c Context ) * ValueBinder {
103
103
return & ValueBinder {
104
- failFast : true ,
105
- ValueFunc : func (sourceParam string ) string {
106
- return c .QueryParam (sourceParam )
107
- },
104
+ failFast : true ,
105
+ ValueFunc : c .QueryParam ,
108
106
ValuesFunc : func (sourceParam string ) []string {
109
107
values , ok := c .QueryParams ()[sourceParam ]
110
108
if ! ok {
@@ -119,10 +117,8 @@ func QueryParamsBinder(c Context) *ValueBinder {
119
117
// PathParamsBinder creates path parameter value binder
120
118
func PathParamsBinder (c Context ) * ValueBinder {
121
119
return & ValueBinder {
122
- failFast : true ,
123
- ValueFunc : func (sourceParam string ) string {
124
- return c .Param (sourceParam )
125
- },
120
+ failFast : true ,
121
+ ValueFunc : c .Param ,
126
122
ValuesFunc : func (sourceParam string ) []string {
127
123
// path parameter should not have multiple values so getting values does not make sense but lets not error out here
128
124
value := c .Param (sourceParam )
Original file line number Diff line number Diff line change @@ -649,8 +649,7 @@ func TestContextRedirect(t *testing.T) {
649
649
}
650
650
651
651
func TestContextStore (t * testing.T ) {
652
- var c Context
653
- c = new (context )
652
+ var c Context = new (context )
654
653
c .Set ("name" , "Jon Snow" )
655
654
testify .Equal (t , "Jon Snow" , c .Get ("name" ))
656
655
}
@@ -687,8 +686,7 @@ func TestContextHandler(t *testing.T) {
687
686
}
688
687
689
688
func TestContext_SetHandler (t * testing.T ) {
690
- var c Context
691
- c = new (context )
689
+ var c Context = new (context )
692
690
693
691
testify .Nil (t , c .Handler ())
694
692
@@ -701,8 +699,7 @@ func TestContext_SetHandler(t *testing.T) {
701
699
func TestContext_Path (t * testing.T ) {
702
700
path := "/pa/th"
703
701
704
- var c Context
705
- c = new (context )
702
+ var c Context = new (context )
706
703
707
704
c .SetPath (path )
708
705
testify .Equal (t , path , c .Path ())
@@ -736,8 +733,7 @@ func TestContext_QueryString(t *testing.T) {
736
733
}
737
734
738
735
func TestContext_Request (t * testing.T ) {
739
- var c Context
740
- c = new (context )
736
+ var c Context = new (context )
741
737
742
738
testify .Nil (t , c .Request ())
743
739
Original file line number Diff line number Diff line change @@ -164,7 +164,7 @@ func TestLoggerCustomTimestamp(t *testing.T) {
164
164
e .ServeHTTP (rec , req )
165
165
166
166
var objs map [string ]* json.RawMessage
167
- if err := json .Unmarshal ([] byte ( buf .String () ), & objs ); err != nil {
167
+ if err := json .Unmarshal (buf .Bytes ( ), & objs ); err != nil {
168
168
panic (err )
169
169
}
170
170
loggedTime := * (* string )(unsafe .Pointer (objs ["time" ]))
Original file line number Diff line number Diff line change @@ -263,6 +263,4 @@ func (store *RateLimiterMemoryStore) cleanupStaleVisitors() {
263
263
/*
264
264
actual time method which is mocked in test file
265
265
*/
266
- var now = func () time.Time {
267
- return time .Now ()
268
- }
266
+ var now = time .Now
Original file line number Diff line number Diff line change @@ -350,9 +350,7 @@ func TestRateLimiterMemoryStore_Allow(t *testing.T) {
350
350
351
351
func TestRateLimiterMemoryStore_cleanupStaleVisitors (t * testing.T ) {
352
352
var inMemoryStore = NewRateLimiterMemoryStoreWithConfig (RateLimiterMemoryStoreConfig {Rate : 1 , Burst : 3 })
353
- now = func () time.Time {
354
- return time .Now ()
355
- }
353
+ now = time .Now
356
354
fmt .Println (now ())
357
355
inMemoryStore .visitors = map [string ]* Visitor {
358
356
"A" : {
You can’t perform that action at this time.
0 commit comments