aboutsummaryrefslogtreecommitdiff
path: root/httpd.go
diff options
context:
space:
mode:
authorShulhan <m.shulhan@gmail.com>2020-07-26 15:11:50 +0700
committerShulhan <m.shulhan@gmail.com>2020-07-26 15:11:50 +0700
commit5fa91b74cdf47e95a4cb8968bd5a505ea24efc6a (patch)
tree24aa20a90e2c284bbeef0f99f8fa09d91358d1ce /httpd.go
parentfb4161eaaf4da54729eb5c74f7b4944d81c64627 (diff)
downloadrescached-5fa91b74cdf47e95a4cb8968bd5a505ea24efc6a.tar.xz
wui: update the hosts block last-updated format
Use the format "Year-month-day hour:minute:second TZ" for last updated value.
Diffstat (limited to 'httpd.go')
-rw-r--r--httpd.go18
1 files changed, 6 insertions, 12 deletions
diff --git a/httpd.go b/httpd.go
index 0b051ef..cbd85cc 100644
--- a/httpd.go
+++ b/httpd.go
@@ -79,15 +79,13 @@ func (srv *Server) httpdRegisterEndpoints() (err error) {
return err
}
- epAPIPostHostsBlock := &http.Endpoint{
+ err = srv.httpd.RegisterEndpoint(&http.Endpoint{
Method: http.RequestMethodPost,
Path: "/api/hosts_block",
RequestType: http.RequestTypeJSON,
ResponseType: http.ResponseTypeJSON,
- Call: srv.apiPostHostsBlock,
- }
-
- err = srv.httpd.RegisterEndpoint(epAPIPostHostsBlock)
+ Call: srv.apiHostsBlockUpdate,
+ })
if err != nil {
return err
}
@@ -203,7 +201,7 @@ func (srv *Server) httpdAPIPostEnvironment(
return json.Marshal(res)
}
-func (srv *Server) apiPostHostsBlock(
+func (srv *Server) apiHostsBlockUpdate(
httpRes stdhttp.ResponseWriter, req *stdhttp.Request, reqBody []byte,
) (
resBody []byte, err error,
@@ -220,10 +218,6 @@ func (srv *Server) apiPostHostsBlock(
Message: "Restarting DNS server",
}
- for x, hb := range hostsBlocks {
- fmt.Printf("apiPostHostsBlock[%d]: %+v\n", x, hb)
- }
-
var mustRestart bool
for _, hb := range srv.env.HostsBlocks {
isUpdated := hb.update(hostsBlocks)
@@ -234,7 +228,7 @@ func (srv *Server) apiPostHostsBlock(
err = srv.env.write(srv.fileConfig)
if err != nil {
- log.Println("apiPostHostsBlock:", err.Error())
+ log.Println("apiHostsBlockUpdate:", err.Error())
res.Code = stdhttp.StatusInternalServerError
res.Message = err.Error()
return json.Marshal(res)
@@ -244,7 +238,7 @@ func (srv *Server) apiPostHostsBlock(
srv.Stop()
err = srv.Start()
if err != nil {
- log.Println("apiPostHostsBlock:", err.Error())
+ log.Println("apiHostsBlockUpdate:", err.Error())
res.Code = stdhttp.StatusInternalServerError
res.Message = err.Error()
}