🚚 Update sideload api urls
This commit is contained in:
parent
da90d12a3a
commit
1ab4c5984e
4
.gitignore
vendored
4
.gitignore
vendored
@ -1,2 +1,4 @@
|
|||||||
/config
|
/config
|
||||||
/letsencrypt
|
/letsencrypt
|
||||||
|
|
||||||
|
.DS_Store
|
@ -43,7 +43,7 @@ func main() {
|
|||||||
log.Warn().Msgf("RoadSign auto generated api credential is %s", credential)
|
log.Warn().Msgf("RoadSign auto generated api credential is %s", credential)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load & init navi
|
// Load & init navigator
|
||||||
if err := navi.ReadInConfig(viper.GetString("paths.configs")); err != nil {
|
if err := navi.ReadInConfig(viper.GetString("paths.configs")); err != nil {
|
||||||
log.Panic().Err(err).Msg("An error occurred when loading configurations.")
|
log.Panic().Err(err).Msg("An error occurred when loading configurations.")
|
||||||
} else {
|
} else {
|
||||||
|
@ -14,4 +14,4 @@ func init() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var AppVersion = "1.2.1"
|
var AppVersion = "2.0.0-delta1"
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
package navi
|
package navi
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/spf13/viper"
|
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/spf13/viper"
|
||||||
|
|
||||||
"github.com/pelletier/go-toml/v2"
|
"github.com/pelletier/go-toml/v2"
|
||||||
)
|
)
|
||||||
@ -14,13 +16,15 @@ var R *RoadApp
|
|||||||
func ReadInConfig(root string) error {
|
func ReadInConfig(root string) error {
|
||||||
instance := &RoadApp{
|
instance := &RoadApp{
|
||||||
Regions: make([]*Region, 0),
|
Regions: make([]*Region, 0),
|
||||||
Traces: make([]RoadTrace, 0, viper.GetInt("performance.traces_limit")),
|
Traces: make([]RoadTrace, 0, viper.GetInt("performance.traces_limit")),
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := filepath.Walk(root, func(fp string, info os.FileInfo, _ error) error {
|
if err := filepath.Walk(root, func(fp string, info os.FileInfo, _ error) error {
|
||||||
var region Region
|
var region Region
|
||||||
if info.IsDir() {
|
if info.IsDir() {
|
||||||
return nil
|
return nil
|
||||||
|
} else if !strings.HasSuffix(info.Name(), ".toml") {
|
||||||
|
return nil
|
||||||
} else if file, err := os.OpenFile(fp, os.O_RDONLY, 0755); err != nil {
|
} else if file, err := os.OpenFile(fp, os.O_RDONLY, 0755); err != nil {
|
||||||
return err
|
return err
|
||||||
} else if data, err := io.ReadAll(file); err != nil {
|
} else if data, err := io.ReadAll(file); err != nil {
|
||||||
@ -33,7 +37,7 @@ func ReadInConfig(root string) error {
|
|||||||
if region.Disabled {
|
if region.Disabled {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
instance.Regions = append(instance.Regions, ®ion)
|
instance.Regions = append(instance.Regions, ®ion)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,11 +54,11 @@ func InitSideload() *fiber.App {
|
|||||||
{
|
{
|
||||||
cgi.Get("/metadata", getMetadata)
|
cgi.Get("/metadata", getMetadata)
|
||||||
cgi.Get("/traces", getTraces)
|
cgi.Get("/traces", getTraces)
|
||||||
cgi.Get("/statistics", getStatistics)
|
cgi.Get("/stats", getStats)
|
||||||
cgi.Get("/sites", getRegions)
|
cgi.Get("/regions", getRegions)
|
||||||
cgi.Get("/sites/cfg/:id", getRegionConfig)
|
cgi.Get("/regions/cfg/:id", getRegionConfig)
|
||||||
cgi.Get("/processes", getApplications)
|
cgi.Get("/applications", getApplications)
|
||||||
cgi.Get("/processes/logs/:id", getApplicationLogs)
|
cgi.Get("/applications/logs/:id", getApplicationLogs)
|
||||||
}
|
}
|
||||||
|
|
||||||
webhooks := app.Group("/webhooks").Name("WebHooks")
|
webhooks := app.Group("/webhooks").Name("WebHooks")
|
||||||
|
@ -7,7 +7,7 @@ import (
|
|||||||
"github.com/samber/lo"
|
"github.com/samber/lo"
|
||||||
)
|
)
|
||||||
|
|
||||||
func getStatistics(c *fiber.Ctx) error {
|
func getStats(c *fiber.Ctx) error {
|
||||||
locations := lo.FlatMap(navi.R.Regions, func(item *navi.Region, idx int) []navi.Location {
|
locations := lo.FlatMap(navi.R.Regions, func(item *navi.Region, idx int) []navi.Location {
|
||||||
return item.Locations
|
return item.Locations
|
||||||
})
|
})
|
||||||
@ -19,8 +19,8 @@ func getStatistics(c *fiber.Ctx) error {
|
|||||||
})
|
})
|
||||||
|
|
||||||
return c.JSON(fiber.Map{
|
return c.JSON(fiber.Map{
|
||||||
"regions": len(navi.R.Regions),
|
"regions": len(navi.R.Regions),
|
||||||
"locations": len(locations),
|
"locations": len(locations),
|
||||||
"destinations": len(destinations),
|
"destinations": len(destinations),
|
||||||
"applications": len(applications),
|
"applications": len(applications),
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user