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:
nemunaire 2026-05-19 22:05:07 +08:00
commit c72558e266
3 changed files with 64 additions and 4 deletions

View file

@ -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(),