Skip to content

Commit

Permalink
Remove unnecessary wrapping of function call
Browse files Browse the repository at this point in the history
  • Loading branch information
withshubh committed Feb 25, 2021
1 parent 27af642 commit f25e77f
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 26 deletions.
12 changes: 0 additions & 12 deletions .deepsource.toml

This file was deleted.

12 changes: 4 additions & 8 deletions binder.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,8 @@ type ValueBinder struct {
// QueryParamsBinder creates query parameter value binder
func QueryParamsBinder(c Context) *ValueBinder {
return &ValueBinder{
failFast: true,
ValueFunc: func(sourceParam string) string {
return c.QueryParam(sourceParam)
},
failFast: true,
ValueFunc: c.QueryParam,
ValuesFunc: func(sourceParam string) []string {
values, ok := c.QueryParams()[sourceParam]
if !ok {
Expand All @@ -119,10 +117,8 @@ func QueryParamsBinder(c Context) *ValueBinder {
// PathParamsBinder creates path parameter value binder
func PathParamsBinder(c Context) *ValueBinder {
return &ValueBinder{
failFast: true,
ValueFunc: func(sourceParam string) string {
return c.Param(sourceParam)
},
failFast: true,
ValueFunc: c.Param,
ValuesFunc: func(sourceParam string) []string {
// path parameter should not have multiple values so getting values does not make sense but lets not error out here
value := c.Param(sourceParam)
Expand Down
4 changes: 1 addition & 3 deletions middleware/rate_limiter.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,4 @@ func (store *RateLimiterMemoryStore) cleanupStaleVisitors() {
/*
actual time method which is mocked in test file
*/
var now = func() time.Time {
return time.Now()
}
var now = time.Now
4 changes: 1 addition & 3 deletions middleware/rate_limiter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,9 +350,7 @@ func TestRateLimiterMemoryStore_Allow(t *testing.T) {

func TestRateLimiterMemoryStore_cleanupStaleVisitors(t *testing.T) {
var inMemoryStore = NewRateLimiterMemoryStoreWithConfig(RateLimiterMemoryStoreConfig{Rate: 1, Burst: 3})
now = func() time.Time {
return time.Now()
}
now = time.Now
fmt.Println(now())
inMemoryStore.visitors = map[string]*Visitor{
"A": {
Expand Down

0 comments on commit f25e77f

Please sign in to comment.