aboutsummaryrefslogtreecommitdiff
path: root/httpd.go
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2022-06-10 20:08:03 +0700
committerShulhan <ms@kilabit.info>2022-06-12 13:02:16 +0700
commitd84e92947fa9d935c374430567b6a3d88a371b5e (patch)
treef33214e40562f09c3c914e6c9beebc42d18cb52c /httpd.go
parentb4e49485f815db682def487191c129f8904d85eb (diff)
downloadrescached-d84e92947fa9d935c374430567b6a3d88a371b5e.tar.xz
_www/block.d: fix the variable names on hosts block.d
In the commit 0b92dbb8463d, we changes the field HostsBlocks in Environment to HostBlockd, but we forgot to changes the code in the web. This changes fix this issue.
Diffstat (limited to 'httpd.go')
-rw-r--r--httpd.go41
1 files changed, 31 insertions, 10 deletions
diff --git a/httpd.go b/httpd.go
index e9e9af0..dedac94 100644
--- a/httpd.go
+++ b/httpd.go
@@ -671,14 +671,35 @@ func (srv *Server) httpApiEnvironmentUpdate(epr *libhttp.EndpointRequest) (resBo
// and remove it from list of hostBlockdFile.
//
// # Request
+//
+// Format,
+//
+// PUT /api/block.d
+// Content-Type: application/json
+//
+// {
+// "<Blockd name>": <Blockd>,
+// ...
+// }
+//
+// # Response
+//
+// On success, it will return the list of Blockd objects.
+//
+// {
+// "data": {
+// "<Blockd name>": <Blockd>,
+// ...
+// }
+// }
func (srv *Server) httpApiBlockdUpdate(epr *libhttp.EndpointRequest) (resBody []byte, err error) {
var (
logp = "httpApiBlockdUpdate"
res = libhttp.EndpointResponse{}
hostBlockd = make(map[string]*Blockd, 0)
- hbx *Blockd
- hby *Blockd
+ blockdReq *Blockd
+ blockdCur *Blockd
)
err = json.Unmarshal(epr.RequestBody, &hostBlockd)
@@ -690,28 +711,28 @@ func (srv *Server) httpApiBlockdUpdate(epr *libhttp.EndpointRequest) (resBody []
res.Code = http.StatusInternalServerError
- for _, hbx = range hostBlockd {
- for _, hby = range srv.env.HostBlockd {
- if hbx.Name != hby.Name {
+ for _, blockdReq = range hostBlockd {
+ for _, blockdCur = range srv.env.HostBlockd {
+ if blockdReq.Name != blockdCur.Name {
continue
}
- if hbx.IsEnabled == hby.IsEnabled {
+ if blockdReq.IsEnabled == blockdCur.IsEnabled {
break
}
- if hbx.IsEnabled {
- err = srv.blockdEnable(hby)
+ if blockdReq.IsEnabled {
+ err = srv.blockdEnable(blockdCur)
if err != nil {
res.Message = err.Error()
return nil, &res
}
} else {
- err = srv.blockdDisable(hby)
+ err = srv.blockdDisable(blockdCur)
if err != nil {
res.Message = err.Error()
return nil, &res
}
- hby.IsEnabled = false
+ blockdCur.IsEnabled = false
}
}
}