aboutsummaryrefslogtreecommitdiff
path: root/httpd.go
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2021-12-19 14:40:18 +0700
committerShulhan <ms@kilabit.info>2021-12-19 14:40:18 +0700
commit7ee3e4ea4658e85a40540212b95206b09686feb7 (patch)
treebabe6a3568f6ead05799e0af31c6d5f6851cfa0b /httpd.go
parent7713203c6bd41053599732869a70467a168e4e55 (diff)
downloadrescached-7ee3e4ea4658e85a40540212b95206b09686feb7.tar.xz
all: refactoring Server initialization
Previously, we initialize the rescached Server by passing the path to configuration file and initialize the environment inside the server. This commit changes it to pass the instance of Environment. The idea is to allow creating and running rescached Server without creating configuration file first.
Diffstat (limited to 'httpd.go')
-rw-r--r--httpd.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/httpd.go b/httpd.go
index 5a392e6..e3a64b0 100644
--- a/httpd.go
+++ b/httpd.go
@@ -356,7 +356,7 @@ func (srv *Server) httpdAPIPostEnvironment(epr *libhttp.EndpointRequest) (resBod
},
}
- newOpts := new(environment)
+ newOpts := new(Environment)
err = json.Unmarshal(epr.RequestBody, newOpts)
if err != nil {
return nil, err
@@ -372,7 +372,7 @@ func (srv *Server) httpdAPIPostEnvironment(epr *libhttp.EndpointRequest) (resBod
fmt.Printf("new options: %+v\n", newOpts)
- err = newOpts.write(srv.fileConfig)
+ err = newOpts.write(srv.env.fileConfig)
if err != nil {
res.Code = http.StatusInternalServerError
res.Message = err.Error()
@@ -442,7 +442,7 @@ func (srv *Server) apiHostsBlockUpdate(epr *libhttp.EndpointRequest) (resBody []
}
}
- err = srv.env.write(srv.fileConfig)
+ err = srv.env.write(srv.env.fileConfig)
if err != nil {
log.Println("apiHostsBlockUpdate:", err.Error())
res.Message = err.Error()