aboutsummaryrefslogtreecommitdiff
path: root/httpd.go
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2022-04-15 01:52:25 +0700
committerShulhan <ms@kilabit.info>2022-04-15 01:52:25 +0700
commit618ffca939c176b2faea4d18de756d58f1110639 (patch)
tree7cc43c0c9a3d7140fe1008775c75b22f4d68f94c /httpd.go
parent4d3ab7f49410eb2b774a7c9e25ba10a1efbd1413 (diff)
downloadrescached-618ffca939c176b2faea4d18de756d58f1110639.tar.xz
all: implement sub command to remove caches by domain name
The "caches" command accept second sub command "remove" that accept single domain name to be removed from caches. This changes affect the HTTP API for caches delete to return the removed answer on the response data.
Diffstat (limited to 'httpd.go')
-rw-r--r--httpd.go6
1 files changed, 4 insertions, 2 deletions
diff --git a/httpd.go b/httpd.go
index d5cb8de..6f4a234 100644
--- a/httpd.go
+++ b/httpd.go
@@ -291,6 +291,8 @@ func (srv *Server) httpdAPIDeleteCaches(epr *libhttp.EndpointRequest) (resBody [
var (
res = libhttp.EndpointResponse{}
q = epr.HttpRequest.Form.Get(paramNameName)
+
+ answers []*dns.Answer
)
if len(q) == 0 {
@@ -299,10 +301,10 @@ func (srv *Server) httpdAPIDeleteCaches(epr *libhttp.EndpointRequest) (resBody [
return nil, &res
}
- srv.dns.RemoveCachesByNames([]string{q})
+ answers = srv.dns.RemoveCachesByNames([]string{q})
res.Code = http.StatusOK
- res.Message = fmt.Sprintf("%q has been removed from caches", q)
+ res.Data = answers
return json.Marshal(&res)
}