Add API endpoint to retrieve a list of country center coordinates
This commit is contained in:
committed by
Daniel Hovie
parent
c75804bc16
commit
f001ed6d06
@@ -3,6 +3,7 @@ package geoip
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
|
"github.com/safing/portbase/api"
|
||||||
"github.com/safing/portbase/modules"
|
"github.com/safing/portbase/modules"
|
||||||
"github.com/safing/portmaster/updates"
|
"github.com/safing/portmaster/updates"
|
||||||
)
|
)
|
||||||
@@ -14,6 +15,19 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func prep() error {
|
func prep() error {
|
||||||
|
if err := api.RegisterEndpoint(api.Endpoint{
|
||||||
|
Path: "intel/geoip/country-centers",
|
||||||
|
Read: api.PermitUser,
|
||||||
|
// Do not attach to module, as the data is always available anyway.
|
||||||
|
StructFunc: func(ar *api.Request) (i interface{}, err error) {
|
||||||
|
return countryCoordinates, nil
|
||||||
|
},
|
||||||
|
Name: "Get Geographic Country Centers",
|
||||||
|
Description: "Returns a map of country centers indexed by ISO-A2 country code",
|
||||||
|
}); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
return module.RegisterEventHook(
|
return module.RegisterEventHook(
|
||||||
updates.ModuleName,
|
updates.ModuleName,
|
||||||
updates.ResourceUpdateEvent,
|
updates.ResourceUpdateEvent,
|
||||||
|
|||||||
Reference in New Issue
Block a user