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

@@ -8,8 +8,9 @@ import (
func registerAPIEndpoints() error {
if err := api.RegisterEndpoint(api.Endpoint{
Path: "network/gateways",
Read: api.PermitUser,
Path: "network/gateways",
Read: api.PermitUser,
BelongsTo: module,
StructFunc: func(ar *api.Request) (i interface{}, err error) {
return Gateways(), nil
},
@@ -20,8 +21,9 @@ func registerAPIEndpoints() error {
}
if err := api.RegisterEndpoint(api.Endpoint{
Path: "network/nameservers",
Read: api.PermitUser,
Path: "network/nameservers",
Read: api.PermitUser,
BelongsTo: module,
StructFunc: func(ar *api.Request) (i interface{}, err error) {
return Nameservers(), nil
},
@@ -32,8 +34,9 @@ func registerAPIEndpoints() error {
}
if err := api.RegisterEndpoint(api.Endpoint{
Path: "network/location",
Read: api.PermitUser,
Path: "network/location",
Read: api.PermitUser,
BelongsTo: module,
StructFunc: func(ar *api.Request) (i interface{}, err error) {
locs, ok := GetInternetLocation()
if ok {