checker: pass EnabledRules to Collect via context
Providers can now skip optional work (network calls, paid API hits) for rules the host has disabled. The /collect request grows an EnabledRules field, and server.handleCollect attaches it to the context with WithEnabledRules; providers read it via EnabledRulesFromContext or the per-rule RuleEnabled helper.
This commit is contained in:
parent
c1de9aca1c
commit
c72558e266
3 changed files with 64 additions and 4 deletions
|
|
@ -325,7 +325,8 @@ func (s *Server) handleCollect(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
data, err := s.provider.Collect(r.Context(), req.Options)
|
||||
ctx := checker.WithEnabledRules(r.Context(), req.EnabledRules)
|
||||
data, err := s.provider.Collect(ctx, req.Options)
|
||||
if err != nil {
|
||||
writeJSON(w, http.StatusInternalServerError, checker.ExternalCollectResponse{
|
||||
Error: err.Error(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue