-
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(pkg/middlewares): use settings for cache and filter constructor…
…s (future proofing for compatibility)
- Loading branch information
Showing
4 changed files
with
64 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package cache | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
) | ||
|
||
type Settings struct { | ||
Cache Cache | ||
} | ||
|
||
var ( | ||
ErrCacheMustBeSet = errors.New("cache must be set") | ||
) | ||
|
||
func (s *Settings) Validate() (err error) { | ||
if s.Cache == nil { | ||
return fmt.Errorf("%w", ErrCacheMustBeSet) | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package filter | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
) | ||
|
||
type Settings struct { | ||
Filter Filter | ||
} | ||
|
||
var ( | ||
ErrFilterMustBeSet = errors.New("filter must be set") | ||
) | ||
|
||
func (s *Settings) Validate() (err error) { | ||
if s.Filter == nil { | ||
return fmt.Errorf("%w", ErrFilterMustBeSet) | ||
} | ||
|
||
return nil | ||
} |