Skip to content

Commit

Permalink
Provided comma separation functionality for module parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
servak committed Aug 16, 2023
1 parent 872f4bd commit 22fb4b0
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
_ "net/http/pprof"
"os"
"os/signal"
"strings"
"sync"
"syscall"

Expand Down Expand Up @@ -100,15 +101,19 @@ func handler(w http.ResponseWriter, r *http.Request, logger log.Logger) {
return
}
modules := make(map[string]*config.Module)
for _, m := range queryModule {
module, moduleOk := sc.C.Modules[m]
if !moduleOk {
sc.RUnlock()
http.Error(w, fmt.Sprintf("Unknown module '%s'", m), http.StatusBadRequest)
snmpRequestErrors.Inc()
return
for _, qm := range queryModule {
for _, m := range strings.Split(qm, ",") {
module, moduleOk := sc.C.Modules[m]
if !moduleOk {
sc.RUnlock()
http.Error(w, fmt.Sprintf("Unknown module '%s'", m), http.StatusBadRequest)
snmpRequestErrors.Inc()
return
}
if _, ok := modules[m]; !ok {
modules[m] = module
}
}
modules[m] = module
}
sc.RUnlock()
logger = log.With(logger, "auth", authName, "target", target)
Expand Down

0 comments on commit 22fb4b0

Please sign in to comment.