Link api endpoints and http handlers to their modules

This commit is contained in:
Daniel
2021-05-17 14:43:17 +02:00
parent 3d5807e3a9
commit 78c56861ab
7 changed files with 28 additions and 12 deletions

View File

@@ -11,6 +11,7 @@ func registerAPI() error {
if err := api.RegisterEndpoint(api.Endpoint{
Path: "dns/clear",
Write: api.PermitUser,
BelongsTo: module,
ActionFunc: clearNameCache,
Name: "Clear cached DNS records",
Description: "Deletes all saved DNS records from the database.",
@@ -21,6 +22,7 @@ func registerAPI() error {
if err := api.RegisterEndpoint(api.Endpoint{
Path: "dns/resolvers",
Read: api.PermitAnyone,
BelongsTo: module,
StructFunc: exportDNSResolvers,
Name: "List DNS Resolvers",
Description: "List currently configured DNS resolvers and their status.",
@@ -29,8 +31,9 @@ func registerAPI() error {
}
if err := api.RegisterEndpoint(api.Endpoint{
Path: `dns/cache/{query:[a-z0-9\.-]{0,512}\.[A-Z]{1,32}}`,
Read: api.PermitUser,
Path: `dns/cache/{query:[a-z0-9\.-]{0,512}\.[A-Z]{1,32}}`,
Read: api.PermitUser,
BelongsTo: module,
RecordFunc: func(r *api.Request) (record.Record, error) {
return recordDatabase.Get(nameRecordsKeyPrefix + r.URLVars["query"])
},