aboutsummaryrefslogtreecommitdiff
path: root/httpd.go
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2022-04-23 00:00:14 +0700
committerShulhan <ms@kilabit.info>2022-04-23 00:16:08 +0700
commit40cc7c23f14332d3aeabee7d25002e984d9062cb (patch)
treefa0863675d09db3a83dc784e80dc3d98421b0bee /httpd.go
parent02abbfec6842d4ef7cc90cec37d0ffb4e39f6892 (diff)
downloadrescached-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.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/httpd.go b/httpd.go
index d1f2dda..beab4a4 100644
--- a/httpd.go
+++ b/httpd.go
@@ -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,
})