summaryrefslogtreecommitdiff
path: root/httpd.go
diff options
context:
space:
mode:
Diffstat (limited to 'httpd.go')
-rw-r--r--httpd.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/httpd.go b/httpd.go
index 2e50b45..09ac8c8 100644
--- a/httpd.go
+++ b/httpd.go
@@ -925,8 +925,16 @@ func (srv *Server) apiHostsdDelete(epr *libhttp.EndpointRequest) (resbody []byte
//
// # Request
//
+// Format,
+//
// GET /api/hosts.d?name=<name>
//
+// Parameters,
+//
+// - name: string, optional, the name of hosts file where content to be
+// fetch.
+// If its empty, it will return all hosts files.
+//
// # Response
//
// On success, it will return list of resource record in JSON format.
@@ -939,6 +947,13 @@ func (srv *Server) apiHostsdGet(epr *libhttp.EndpointRequest) (resbody []byte, e
found bool
)
+ name = strings.TrimSpace(name)
+ if len(name) == 0 {
+ res.Code = http.StatusOK
+ res.Data = srv.env.HostsFiles
+ return json.Marshal(&res)
+ }
+
hf, found = srv.env.HostsFiles[name]
if !found {
res.Code = http.StatusNotFound