mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2026-01-15 13:26:08 +00:00
filtering: imp code
Some checks failed
build / test (macOS-latest) (push) Has been cancelled
build / test (ubuntu-latest) (push) Has been cancelled
build / test (windows-latest) (push) Has been cancelled
build / build-release (push) Has been cancelled
build / notify (push) Has been cancelled
lint / go-lint (push) Has been cancelled
lint / eslint (push) Has been cancelled
lint / notify (push) Has been cancelled
Some checks failed
build / test (macOS-latest) (push) Has been cancelled
build / test (ubuntu-latest) (push) Has been cancelled
build / test (windows-latest) (push) Has been cancelled
build / build-release (push) Has been cancelled
build / notify (push) Has been cancelled
lint / go-lint (push) Has been cancelled
lint / eslint (push) Has been cancelled
lint / notify (push) Has been cancelled
This commit is contained in:
@@ -229,20 +229,22 @@ func (d *DNSFilter) handleRewriteSettings(w http.ResponseWriter, r *http.Request
|
||||
Enabled: protectedBool(d.confMu, &d.conf.RewritesEnabled),
|
||||
}
|
||||
|
||||
aghhttp.WriteJSONResponseOK(w, r, resp)
|
||||
aghhttp.WriteJSONResponseOK(r.Context(), d.logger, w, r, resp)
|
||||
}
|
||||
|
||||
// handleRewriteSettingsUpdate is the handler for the PUT
|
||||
// /control/rewrite/settings/update HTTP API.
|
||||
func (d *DNSFilter) handleRewriteSettingsUpdate(w http.ResponseWriter, r *http.Request) {
|
||||
ctx := r.Context()
|
||||
|
||||
req := &rewriteSettings{}
|
||||
err := json.NewDecoder(r.Body).Decode(req)
|
||||
if err != nil {
|
||||
aghhttp.Error(r, w, http.StatusBadRequest, "json.Decode: %s", err)
|
||||
aghhttp.ErrorAndLog(ctx, d.logger, r, w, http.StatusBadRequest, "json.Decode: %s", err)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
setProtectedBool(d.confMu, &d.conf.RewritesEnabled, req.Enabled)
|
||||
d.conf.ConfModifier.Apply(r.Context())
|
||||
d.conf.ConfModifier.Apply(ctx)
|
||||
}
|
||||
|
||||
@@ -364,8 +364,10 @@ func TestDNSFilter_HandleRewriteSettings(t *testing.T) {
|
||||
d, err := filtering.New(&filtering.Config{
|
||||
Logger: testLogger,
|
||||
ConfModifier: confModifier,
|
||||
HTTPRegister: func(_, url string, handler http.HandlerFunc) {
|
||||
handlers[url] = handler
|
||||
HTTPReg: &aghtest.Registrar{
|
||||
OnRegister: func(_, url string, handler http.HandlerFunc) {
|
||||
handlers[url] = handler
|
||||
},
|
||||
},
|
||||
RewritesEnabled: false,
|
||||
}, nil)
|
||||
|
||||
Reference in New Issue
Block a user