Skip to content

Commit 7ba4fda

Browse files
yhabteaboxzi
authored andcommitted
listener: use HTTP X-* header constants from IGL
1 parent c5578f1 commit 7ba4fda

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

internal/listener/listener.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"fmt"
99
"github.com/icinga/icinga-go-library/database"
1010
"github.com/icinga/icinga-go-library/logging"
11+
"github.com/icinga/icinga-go-library/notifications"
1112
baseEv "github.com/icinga/icinga-go-library/notifications/event"
1213
"github.com/icinga/icinga-notifications/internal"
1314
"github.com/icinga/icinga-notifications/internal/config"
@@ -128,8 +129,8 @@ func (l *Listener) ProcessEvent(w http.ResponseWriter, r *http.Request) {
128129
return
129130
}
130131

131-
ruleIdsStr := r.Header.Get("X-Rule-Ids")
132-
ruleVersion := r.Header.Get("X-Rule-Version")
132+
ruleIdsStr := r.Header.Get(notifications.XIcingaRulesId)
133+
ruleVersion := r.Header.Get(notifications.XIcingaRulesVersion)
133134

134135
// If the client uses an outdated rules version, reject the request but send also the current rules version
135136
// and rules for this source back to the client, so it can retry the request with the updated rules.
@@ -146,7 +147,7 @@ func (l *Listener) ProcessEvent(w http.ResponseWriter, r *http.Request) {
146147

147148
var ev event.Event
148149
if err := ev.LoadMatchedRulesFromString(ruleIdsStr); err != nil {
149-
abort(http.StatusBadRequest, nil, "cannot parse X-Rule-Ids: %v", err)
150+
abort(http.StatusBadRequest, nil, "cannot parse %s header: %v", notifications.XIcingaRulesId, err)
150151
return
151152
}
152153

0 commit comments

Comments
 (0)