From 9b770873859186c9424c8d108812e32ddff33bad Mon Sep 17 00:00:00 2001 From: Stanislav Chzhen Date: Fri, 21 Jul 2023 14:29:50 +0300 Subject: [PATCH] all: imp naming --- internal/aghhttp/json.go | 34 +++++++++++----------------- internal/dhcpd/http_unix.go | 6 ++--- internal/dhcpd/http_windows.go | 2 +- internal/dnsforward/access.go | 2 +- internal/dnsforward/http.go | 4 ++-- internal/filtering/blocked.go | 8 +++---- internal/filtering/http.go | 10 ++++---- internal/filtering/rewritehttp.go | 2 +- internal/filtering/safesearchhttp.go | 2 +- internal/home/clientshttp.go | 4 ++-- internal/home/control.go | 2 +- internal/home/controlinstall.go | 4 ++-- internal/home/controlupdate.go | 4 ++-- internal/home/i18n.go | 2 +- internal/home/profilehttp.go | 2 +- internal/home/tls.go | 2 +- internal/next/websvc/dns.go | 8 +++---- internal/next/websvc/http.go | 4 ++-- internal/next/websvc/settings.go | 2 +- internal/next/websvc/system.go | 2 +- internal/querylog/http.go | 6 ++--- internal/stats/http.go | 6 ++--- 22 files changed, 55 insertions(+), 63 deletions(-) diff --git a/internal/aghhttp/json.go b/internal/aghhttp/json.go index 0f3742f080d..b7eca7679c5 100644 --- a/internal/aghhttp/json.go +++ b/internal/aghhttp/json.go @@ -86,35 +86,27 @@ func (t *JSONTime) UnmarshalJSON(b []byte) (err error) { return nil } -// WriteJSONResponse sets the content-type header in w.Header() to -// "application/json", writes a header with a "200 OK" status, encodes resp to -// w, calls [Error] on any returned error, and returns it as well. -func WriteJSONResponse(w http.ResponseWriter, r *http.Request, resp any) (err error) { - return WriteJSONResponseCode(w, r, http.StatusOK, resp) -} - -// WriteJSONResponseCode is like [WriteJSONResponse] but adds the ability to -// redefine the status code. -func WriteJSONResponseCode(w http.ResponseWriter, r *http.Request, code int, resp any) (err error) { +// WriteJSONResponse writes headers with the code, encodes resp into w, and logs +// any errors it encounters. r is used to get additional information from the +// request. +func WriteJSONResponse(w http.ResponseWriter, r *http.Request, code int, resp any) { h := w.Header() h.Set(httphdr.ContentType, HdrValApplicationJSON) h.Set(httphdr.Server, UserAgent()) w.WriteHeader(code) - err = json.NewEncoder(w).Encode(resp) + err := json.NewEncoder(w).Encode(resp) if err != nil { - Error(r, w, http.StatusInternalServerError, "encoding resp: %s", err) + log.Error("aghhttp: writing json resp to %s %s: %s", r.Method, r.URL.Path, err) } - - return err } -// WriteJSONOKResponse writes headers with the code 200 OK, encodes v into w, +// WriteJSONResponseOK writes headers with the code 200 OK, encodes v into w, // and logs any errors it encounters. r is used to get additional information // from the request. -func WriteJSONOKResponse(w http.ResponseWriter, r *http.Request, v any) { - _ = WriteJSONResponseCode(w, r, http.StatusOK, v) +func WriteJSONResponseOK(w http.ResponseWriter, r *http.Request, v any) { + WriteJSONResponse(w, r, http.StatusOK, v) } // ErrorCode is the error code as used by the HTTP API. See the ErrorCode @@ -137,13 +129,13 @@ type HTTPAPIErrorResp struct { Msg string `json:"msg"` } -// WriteJSONErrorResponse encodes err as a JSON error into w, and logs any +// WriteJSONResponseError encodes err as a JSON error into w, and logs any // errors it encounters. r is used to get additional information from the // request. -func WriteJSONErrorResponse(w http.ResponseWriter, r *http.Request, err error) { - log.Error("websvc: %s %s: %s", r.Method, r.URL.Path, err) +func WriteJSONResponseError(w http.ResponseWriter, r *http.Request, err error) { + log.Error("aghhttp: writing json error to %s %s: %s", r.Method, r.URL.Path, err) - _ = WriteJSONResponseCode(w, r, http.StatusUnprocessableEntity, &HTTPAPIErrorResp{ + WriteJSONResponse(w, r, http.StatusUnprocessableEntity, &HTTPAPIErrorResp{ Code: ErrorCodeTMP000, Msg: err.Error(), }) diff --git a/internal/dhcpd/http_unix.go b/internal/dhcpd/http_unix.go index b07f95433a0..2ba693ccbd4 100644 --- a/internal/dhcpd/http_unix.go +++ b/internal/dhcpd/http_unix.go @@ -146,7 +146,7 @@ func (s *server) handleDHCPStatus(w http.ResponseWriter, r *http.Request) { status.Leases = leasesToDynamic(s.Leases(LeasesDynamic)) status.StaticLeases = leasesToStatic(s.Leases(LeasesStatic)) - _ = aghhttp.WriteJSONResponse(w, r, status) + aghhttp.WriteJSONResponseOK(w, r, status) } func (s *server) enableDHCP(ifaceName string) (code int, err error) { @@ -395,7 +395,7 @@ func (s *server) handleDHCPInterfaces(w http.ResponseWriter, r *http.Request) { } } - _ = aghhttp.WriteJSONResponse(w, r, resp) + aghhttp.WriteJSONResponseOK(w, r, resp) } // newNetInterfaceJSON creates a JSON object from a [net.Interface] iface. @@ -547,7 +547,7 @@ func (s *server) handleDHCPFindActiveServer(w http.ResponseWriter, r *http.Reque setOtherDHCPResult(ifaceName, result) - _ = aghhttp.WriteJSONResponse(w, r, result) + aghhttp.WriteJSONResponseOK(w, r, result) } // setOtherDHCPResult sets the results of the check for another DHCP server in diff --git a/internal/dhcpd/http_windows.go b/internal/dhcpd/http_windows.go index fda72d4876d..eb82b86160b 100644 --- a/internal/dhcpd/http_windows.go +++ b/internal/dhcpd/http_windows.go @@ -24,7 +24,7 @@ type jsonError struct { // TODO(a.garipov): Either take the logger from the server after we've // refactored logging or make this not a method of *Server. func (s *server) notImplemented(w http.ResponseWriter, r *http.Request) { - _ = aghhttp.WriteJSONResponseCode(w, r, http.StatusNotImplemented, &jsonError{ + aghhttp.WriteJSONResponse(w, r, http.StatusNotImplemented, &jsonError{ Message: aghos.Unsupported("dhcp").Error(), }) } diff --git a/internal/dnsforward/access.go b/internal/dnsforward/access.go index 12f5f3c70e3..ab8752719c8 100644 --- a/internal/dnsforward/access.go +++ b/internal/dnsforward/access.go @@ -183,7 +183,7 @@ func (s *Server) accessListJSON() (j accessListJSON) { } func (s *Server) handleAccessList(w http.ResponseWriter, r *http.Request) { - _ = aghhttp.WriteJSONResponse(w, r, s.accessListJSON()) + aghhttp.WriteJSONResponseOK(w, r, s.accessListJSON()) } // validateAccessSet checks the internal accessListJSON lists. To search for diff --git a/internal/dnsforward/http.go b/internal/dnsforward/http.go index e95459c716b..470caff9c6d 100644 --- a/internal/dnsforward/http.go +++ b/internal/dnsforward/http.go @@ -170,7 +170,7 @@ func (s *Server) getDNSConfig() (c *jsonDNSConfig) { // handleGetConfig handles requests to the GET /control/dns_info endpoint. func (s *Server) handleGetConfig(w http.ResponseWriter, r *http.Request) { resp := s.getDNSConfig() - _ = aghhttp.WriteJSONResponse(w, r, resp) + aghhttp.WriteJSONResponseOK(w, r, resp) } func (req *jsonDNSConfig) checkBlockingMode() (err error) { @@ -757,7 +757,7 @@ func (s *Server) handleTestUpstreamDNS(w http.ResponseWriter, r *http.Request) { } } - _ = aghhttp.WriteJSONResponse(w, r, result) + aghhttp.WriteJSONResponseOK(w, r, result) } // handleCacheClear is the handler for the POST /control/cache_clear HTTP API. diff --git a/internal/filtering/blocked.go b/internal/filtering/blocked.go index 14954c421f7..2dba12da3ea 100644 --- a/internal/filtering/blocked.go +++ b/internal/filtering/blocked.go @@ -114,11 +114,11 @@ func (d *DNSFilter) ApplyBlockedServicesList(setts *Settings, list []string) { } func (d *DNSFilter) handleBlockedServicesIDs(w http.ResponseWriter, r *http.Request) { - _ = aghhttp.WriteJSONResponse(w, r, serviceIDs) + aghhttp.WriteJSONResponseOK(w, r, serviceIDs) } func (d *DNSFilter) handleBlockedServicesAll(w http.ResponseWriter, r *http.Request) { - _ = aghhttp.WriteJSONResponse(w, r, struct { + aghhttp.WriteJSONResponseOK(w, r, struct { BlockedServices []blockedService `json:"blocked_services"` }{ BlockedServices: blockedServices, @@ -134,7 +134,7 @@ func (d *DNSFilter) handleBlockedServicesList(w http.ResponseWriter, r *http.Req list := d.Config.BlockedServices.IDs d.confLock.RUnlock() - _ = aghhttp.WriteJSONResponse(w, r, list) + aghhttp.WriteJSONResponseOK(w, r, list) } // handleBlockedServicesSet is the handler for the POST @@ -170,7 +170,7 @@ func (d *DNSFilter) handleBlockedServicesGet(w http.ResponseWriter, r *http.Requ bsvc = d.Config.BlockedServices.Clone() }() - _ = aghhttp.WriteJSONResponse(w, r, bsvc) + aghhttp.WriteJSONResponseOK(w, r, bsvc) } // handleBlockedServicesUpdate is the handler for the PUT diff --git a/internal/filtering/http.go b/internal/filtering/http.go index 0c89d2a3db4..faee0588942 100644 --- a/internal/filtering/http.go +++ b/internal/filtering/http.go @@ -301,7 +301,7 @@ func (d *DNSFilter) handleFilteringRefresh(w http.ResponseWriter, r *http.Reques return } - _ = aghhttp.WriteJSONResponse(w, r, resp) + aghhttp.WriteJSONResponseOK(w, r, resp) } type filterJSON struct { @@ -354,7 +354,7 @@ func (d *DNSFilter) handleFilteringStatus(w http.ResponseWriter, r *http.Request resp.UserRules = d.UserRules d.filtersMu.RUnlock() - _ = aghhttp.WriteJSONResponse(w, r, resp) + aghhttp.WriteJSONResponseOK(w, r, resp) } // Set filtering configuration @@ -456,7 +456,7 @@ func (d *DNSFilter) handleCheckHost(w http.ResponseWriter, r *http.Request) { } } - _ = aghhttp.WriteJSONResponse(w, r, resp) + aghhttp.WriteJSONResponseOK(w, r, resp) } // setProtectedBool sets the value of a boolean pointer under a lock. l must @@ -504,7 +504,7 @@ func (d *DNSFilter) handleSafeBrowsingStatus(w http.ResponseWriter, r *http.Requ Enabled: protectedBool(&d.confLock, &d.Config.SafeBrowsingEnabled), } - _ = aghhttp.WriteJSONResponse(w, r, resp) + aghhttp.WriteJSONResponseOK(w, r, resp) } // handleParentalEnable is the handler for the POST /control/parental/enable @@ -530,7 +530,7 @@ func (d *DNSFilter) handleParentalStatus(w http.ResponseWriter, r *http.Request) Enabled: protectedBool(&d.confLock, &d.Config.ParentalEnabled), } - _ = aghhttp.WriteJSONResponse(w, r, resp) + aghhttp.WriteJSONResponseOK(w, r, resp) } // RegisterFilteringHandlers - register handlers diff --git a/internal/filtering/rewritehttp.go b/internal/filtering/rewritehttp.go index fea5a650572..b3dc275a853 100644 --- a/internal/filtering/rewritehttp.go +++ b/internal/filtering/rewritehttp.go @@ -28,7 +28,7 @@ func (d *DNSFilter) handleRewriteList(w http.ResponseWriter, r *http.Request) { } d.confLock.Unlock() - _ = aghhttp.WriteJSONResponse(w, r, arr) + aghhttp.WriteJSONResponseOK(w, r, arr) } func (d *DNSFilter) handleRewriteAdd(w http.ResponseWriter, r *http.Request) { diff --git a/internal/filtering/safesearchhttp.go b/internal/filtering/safesearchhttp.go index 6048cfea85e..d1358a2fdb9 100644 --- a/internal/filtering/safesearchhttp.go +++ b/internal/filtering/safesearchhttp.go @@ -36,7 +36,7 @@ func (d *DNSFilter) handleSafeSearchStatus(w http.ResponseWriter, r *http.Reques resp = d.Config.SafeSearchConf }() - _ = aghhttp.WriteJSONResponse(w, r, resp) + aghhttp.WriteJSONResponseOK(w, r, resp) } // handleSafeSearchSettings is the handler for PUT /control/safesearch/settings diff --git a/internal/home/clientshttp.go b/internal/home/clientshttp.go index febf5c43378..240ef4de019 100644 --- a/internal/home/clientshttp.go +++ b/internal/home/clientshttp.go @@ -125,7 +125,7 @@ func (clients *clientsContainer) handleGetClients(w http.ResponseWriter, r *http data.Tags = clientTags - _ = aghhttp.WriteJSONResponse(w, r, data) + aghhttp.WriteJSONResponseOK(w, r, data) } // jsonToClient converts JSON object to Client object. @@ -364,7 +364,7 @@ func (clients *clientsContainer) handleFindClient(w http.ResponseWriter, r *http }) } - _ = aghhttp.WriteJSONResponse(w, r, data) + aghhttp.WriteJSONResponseOK(w, r, data) } // findRuntime looks up the IP in runtime and temporary storages, like diff --git a/internal/home/control.go b/internal/home/control.go index 48afcf71d47..f24895e84d5 100644 --- a/internal/home/control.go +++ b/internal/home/control.go @@ -170,7 +170,7 @@ func handleStatus(w http.ResponseWriter, r *http.Request) { resp.IsDHCPAvailable = Context.dhcpServer != nil } - _ = aghhttp.WriteJSONResponse(w, r, resp) + aghhttp.WriteJSONResponseOK(w, r, resp) } // ------------------------ diff --git a/internal/home/controlinstall.go b/internal/home/controlinstall.go index c9503fa052b..af8ba4d9514 100644 --- a/internal/home/controlinstall.go +++ b/internal/home/controlinstall.go @@ -59,7 +59,7 @@ func (web *webAPI) handleInstallGetAddresses(w http.ResponseWriter, r *http.Requ data.Interfaces[iface.Name] = iface } - _ = aghhttp.WriteJSONResponse(w, r, data) + aghhttp.WriteJSONResponseOK(w, r, data) } type checkConfReqEnt struct { @@ -190,7 +190,7 @@ func (web *webAPI) handleInstallCheckConfig(w http.ResponseWriter, r *http.Reque resp.StaticIP = handleStaticIP(req.DNS.IP, req.SetStaticIP) } - _ = aghhttp.WriteJSONResponse(w, r, resp) + aghhttp.WriteJSONResponseOK(w, r, resp) } // handleStaticIP - handles static IP request diff --git a/internal/home/controlupdate.go b/internal/home/controlupdate.go index 434286bacfb..e96751fda15 100644 --- a/internal/home/controlupdate.go +++ b/internal/home/controlupdate.go @@ -33,7 +33,7 @@ func handleVersionJSON(w http.ResponseWriter, r *http.Request) { resp := &versionResponse{} if Context.disableUpdate { resp.Disabled = true - _ = aghhttp.WriteJSONResponse(w, r, resp) + aghhttp.WriteJSONResponseOK(w, r, resp) return } @@ -68,7 +68,7 @@ func handleVersionJSON(w http.ResponseWriter, r *http.Request) { return } - _ = aghhttp.WriteJSONResponse(w, r, resp) + aghhttp.WriteJSONResponseOK(w, r, resp) } // requestVersionInfo sets the VersionInfo field of resp if it can reach the diff --git a/internal/home/i18n.go b/internal/home/i18n.go index d9e3435c826..267205d3a83 100644 --- a/internal/home/i18n.go +++ b/internal/home/i18n.go @@ -58,7 +58,7 @@ type languageJSON struct { func handleI18nCurrentLanguage(w http.ResponseWriter, r *http.Request) { log.Printf("home: language is %s", config.Language) - _ = aghhttp.WriteJSONResponse(w, r, &languageJSON{ + aghhttp.WriteJSONResponseOK(w, r, &languageJSON{ Language: config.Language, }) } diff --git a/internal/home/profilehttp.go b/internal/home/profilehttp.go index 12e036c3734..91e36f28916 100644 --- a/internal/home/profilehttp.go +++ b/internal/home/profilehttp.go @@ -61,7 +61,7 @@ func handleGetProfile(w http.ResponseWriter, r *http.Request) { } }() - _ = aghhttp.WriteJSONResponse(w, r, resp) + aghhttp.WriteJSONResponseOK(w, r, resp) } // handlePutProfile is the handler for PUT /control/profile/update endpoint. diff --git a/internal/home/tls.go b/internal/home/tls.go index c42d5175331..004e9412516 100644 --- a/internal/home/tls.go +++ b/internal/home/tls.go @@ -770,7 +770,7 @@ func marshalTLS(w http.ResponseWriter, r *http.Request, data tlsConfig) { data.PrivateKey = "" } - _ = aghhttp.WriteJSONResponse(w, r, data) + aghhttp.WriteJSONResponseOK(w, r, data) } // registerWebHandlers registers HTTP handlers for TLS configuration. diff --git a/internal/next/websvc/dns.go b/internal/next/websvc/dns.go index 1761eedaba1..39f05d226ad 100644 --- a/internal/next/websvc/dns.go +++ b/internal/next/websvc/dns.go @@ -54,7 +54,7 @@ func (svc *Service) handlePatchSettingsDNS(w http.ResponseWriter, r *http.Reques err := json.NewDecoder(r.Body).Decode(&req) if err != nil { - aghhttp.WriteJSONErrorResponse(w, r, fmt.Errorf("decoding: %w", err)) + aghhttp.WriteJSONResponseError(w, r, fmt.Errorf("decoding: %w", err)) return } @@ -72,7 +72,7 @@ func (svc *Service) handlePatchSettingsDNS(w http.ResponseWriter, r *http.Reques ctx := r.Context() err = svc.confMgr.UpdateDNS(ctx, newConf) if err != nil { - aghhttp.WriteJSONErrorResponse(w, r, fmt.Errorf("updating: %w", err)) + aghhttp.WriteJSONResponseError(w, r, fmt.Errorf("updating: %w", err)) return } @@ -80,12 +80,12 @@ func (svc *Service) handlePatchSettingsDNS(w http.ResponseWriter, r *http.Reques newSvc := svc.confMgr.DNS() err = newSvc.Start() if err != nil { - aghhttp.WriteJSONErrorResponse(w, r, fmt.Errorf("starting new service: %w", err)) + aghhttp.WriteJSONResponseError(w, r, fmt.Errorf("starting new service: %w", err)) return } - aghhttp.WriteJSONOKResponse(w, r, &HTTPAPIDNSSettings{ + aghhttp.WriteJSONResponseOK(w, r, &HTTPAPIDNSSettings{ Addresses: newConf.Addresses, BootstrapServers: newConf.BootstrapServers, UpstreamServers: newConf.UpstreamServers, diff --git a/internal/next/websvc/http.go b/internal/next/websvc/http.go index c89fd1e80ff..38a35097c4a 100644 --- a/internal/next/websvc/http.go +++ b/internal/next/websvc/http.go @@ -47,7 +47,7 @@ func (svc *Service) handlePatchSettingsHTTP(w http.ResponseWriter, r *http.Reque err := json.NewDecoder(r.Body).Decode(&req) if err != nil { - aghhttp.WriteJSONErrorResponse(w, r, fmt.Errorf("decoding: %w", err)) + aghhttp.WriteJSONResponseError(w, r, fmt.Errorf("decoding: %w", err)) return } @@ -62,7 +62,7 @@ func (svc *Service) handlePatchSettingsHTTP(w http.ResponseWriter, r *http.Reque ForceHTTPS: svc.forceHTTPS, } - aghhttp.WriteJSONOKResponse(w, r, &HTTPAPIHTTPSettings{ + aghhttp.WriteJSONResponseOK(w, r, &HTTPAPIHTTPSettings{ Addresses: newConf.Addresses, SecureAddresses: newConf.SecureAddresses, Timeout: aghhttp.JSONDuration(newConf.Timeout), diff --git a/internal/next/websvc/settings.go b/internal/next/websvc/settings.go index f559efd2c4b..44364ca3a9c 100644 --- a/internal/next/websvc/settings.go +++ b/internal/next/websvc/settings.go @@ -27,7 +27,7 @@ func (svc *Service) handleGetSettingsAll(w http.ResponseWriter, r *http.Request) httpConf := webSvc.Config() // TODO(a.garipov): Add all currently supported parameters. - aghhttp.WriteJSONOKResponse(w, r, &RespGetV1SettingsAll{ + aghhttp.WriteJSONResponseOK(w, r, &RespGetV1SettingsAll{ DNS: &HTTPAPIDNSSettings{ Addresses: dnsConf.Addresses, BootstrapServers: dnsConf.BootstrapServers, diff --git a/internal/next/websvc/system.go b/internal/next/websvc/system.go index 10351e1613f..d4ca34ad32a 100644 --- a/internal/next/websvc/system.go +++ b/internal/next/websvc/system.go @@ -24,7 +24,7 @@ type RespGetV1SystemInfo struct { // handleGetV1SystemInfo is the handler for the GET /api/v1/system/info HTTP // API. func (svc *Service) handleGetV1SystemInfo(w http.ResponseWriter, r *http.Request) { - aghhttp.WriteJSONOKResponse(w, r, &RespGetV1SystemInfo{ + aghhttp.WriteJSONResponseOK(w, r, &RespGetV1SystemInfo{ Arch: runtime.GOARCH, Channel: version.Channel(), OS: runtime.GOOS, diff --git a/internal/querylog/http.go b/internal/querylog/http.go index 1a29e23de34..7a5c24a9289 100644 --- a/internal/querylog/http.go +++ b/internal/querylog/http.go @@ -93,7 +93,7 @@ func (l *queryLog) handleQueryLog(w http.ResponseWriter, r *http.Request) { resp := entriesToJSON(entries, oldest, l.anonymizer.Load()) - _ = aghhttp.WriteJSONResponse(w, r, resp) + aghhttp.WriteJSONResponseOK(w, r, resp) } // handleQueryLogClear is the handler for the POST /control/querylog/clear HTTP @@ -118,7 +118,7 @@ func (l *queryLog) handleQueryLogInfo(w http.ResponseWriter, r *http.Request) { ivl = timeutil.Day * 90 } - _ = aghhttp.WriteJSONResponse(w, r, configJSON{ + aghhttp.WriteJSONResponseOK(w, r, configJSON{ Enabled: aghalg.BoolToNullBool(l.conf.Enabled), Interval: ivl.Hours() / 24, AnonymizeClientIP: aghalg.BoolToNullBool(l.conf.AnonymizeClientIP), @@ -143,7 +143,7 @@ func (l *queryLog) handleGetQueryLogConfig(w http.ResponseWriter, r *http.Reques slices.Sort(resp.Ignored) - _ = aghhttp.WriteJSONResponse(w, r, resp) + aghhttp.WriteJSONResponseOK(w, r, resp) } // AnonymizeIP masks ip to anonymize the client if the ip is a valid one. diff --git a/internal/stats/http.go b/internal/stats/http.go index 38f6be55648..da55925e629 100644 --- a/internal/stats/http.go +++ b/internal/stats/http.go @@ -67,7 +67,7 @@ func (s *StatsCtx) handleStats(w http.ResponseWriter, r *http.Request) { return } - _ = aghhttp.WriteJSONResponse(w, r, resp) + aghhttp.WriteJSONResponseOK(w, r, resp) } // configResp is the response to the GET /control/stats_info. @@ -116,7 +116,7 @@ func (s *StatsCtx) handleStatsInfo(w http.ResponseWriter, r *http.Request) { resp.IntervalDays = 0 } - _ = aghhttp.WriteJSONResponse(w, r, resp) + aghhttp.WriteJSONResponseOK(w, r, resp) } // handleGetStatsConfig is the handler for the GET /control/stats/config HTTP @@ -136,7 +136,7 @@ func (s *StatsCtx) handleGetStatsConfig(w http.ResponseWriter, r *http.Request) slices.Sort(resp.Ignored) - _ = aghhttp.WriteJSONResponse(w, r, resp) + aghhttp.WriteJSONResponseOK(w, r, resp) } // handleStatsConfig is the handler for the POST /control/stats_config HTTP API.