diff options
| author | Shulhan <ms@kilabit.info> | 2022-04-23 00:00:14 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2022-04-23 00:16:08 +0700 |
| commit | 40cc7c23f14332d3aeabee7d25002e984d9062cb (patch) | |
| tree | fa0863675d09db3a83dc784e80dc3d98421b0bee /httpd.go | |
| parent | 02abbfec6842d4ef7cc90cec37d0ffb4e39f6892 (diff) | |
| download | rescached-40cc7c23f14332d3aeabee7d25002e984d9062cb.tar.xz | |
all: change the hosts.d HTTP API request type to form and query
Using dynamic value in the URL path is not a good practice, so we
move the API for hosts.d to create, delete, and get to form and query
parameters.
Diffstat (limited to 'httpd.go')
| -rw-r--r-- | httpd.go | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -36,7 +36,7 @@ const ( apiEnvironment = "/api/environment" - apiHostsDir = "/api/hosts.d/:name" + apiHostsDir = "/api/hosts.d" apiHostsDirRR = "/api/hosts.d/:name/rr" apiZone = "/api/zone.d/:name" @@ -163,9 +163,9 @@ func (srv *Server) httpdRegisterEndpoints() (err error) { // Register API to create new hosts file. err = srv.httpd.RegisterEndpoint(&libhttp.Endpoint{ - Method: libhttp.RequestMethodPut, + Method: libhttp.RequestMethodPost, Path: apiHostsDir, - RequestType: libhttp.RequestTypeNone, + RequestType: libhttp.RequestTypeForm, ResponseType: libhttp.ResponseTypeJSON, Call: srv.apiHostsFileCreate, }) @@ -176,7 +176,7 @@ func (srv *Server) httpdRegisterEndpoints() (err error) { err = srv.httpd.RegisterEndpoint(&libhttp.Endpoint{ Method: libhttp.RequestMethodGet, Path: apiHostsDir, - RequestType: libhttp.RequestTypeNone, + RequestType: libhttp.RequestTypeQuery, ResponseType: libhttp.ResponseTypeJSON, Call: srv.apiHostsFileGet, }) @@ -187,7 +187,7 @@ func (srv *Server) httpdRegisterEndpoints() (err error) { err = srv.httpd.RegisterEndpoint(&libhttp.Endpoint{ Method: libhttp.RequestMethodDelete, Path: apiHostsDir, - RequestType: libhttp.RequestTypeNone, + RequestType: libhttp.RequestTypeQuery, ResponseType: libhttp.ResponseTypeJSON, Call: srv.apiHostsFileDelete, }) |
