Skip to content

Commit

Permalink
Changed config file parser to handle both "interceptors" and "interce…
Browse files Browse the repository at this point in the history
…ptions" key.
  • Loading branch information
paramaw committed Sep 20, 2021
1 parent ccd6870 commit fc7fc64
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions cmd/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,17 @@ var serveCmd = &cobra.Command{

// sets the interceptors
var rs []interceptors.Interceptor
viper.UnmarshalKey("interceptors", &rs)
viper.UnmarshalKey("interceptions", &rs)

// Handle both, interceptions and interceptors
if len(rs) == 0 {
viper.UnmarshalKey("interceptors", &rs)
}

if rs != nil {
// validates the interceptors
if ok, errs := interceptors.ValidateAll(rs); !ok || len(errs) > 0 {
log.Fatal("Your config file has invalid interceptors:", errs)
log.Fatal("Your config file has invalid interceptions:", errs)
}

server.Interceptors = rs
Expand Down

0 comments on commit fc7fc64

Please sign in to comment.