diff options
Diffstat (limited to 'httpd.go')
| -rw-r--r-- | httpd.go | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -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 |
