diff options
| author | Shulhan <m.shulhan@gmail.com> | 2020-07-26 15:11:50 +0700 |
|---|---|---|
| committer | Shulhan <m.shulhan@gmail.com> | 2020-07-26 15:11:50 +0700 |
| commit | 5fa91b74cdf47e95a4cb8968bd5a505ea24efc6a (patch) | |
| tree | 24aa20a90e2c284bbeef0f99f8fa09d91358d1ce /httpd.go | |
| parent | fb4161eaaf4da54729eb5c74f7b4944d81c64627 (diff) | |
| download | rescached-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.go | 18 |
1 files changed, 6 insertions, 12 deletions
@@ -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() } |
