moved http api

This commit is contained in:
Annika Hannig 2021-10-22 22:40:03 +02:00
parent 977e4db816
commit 39e2605707
23 changed files with 24 additions and 53 deletions

View File

@ -30,7 +30,7 @@ type RoutesStoreStats struct {
} }
// Log writes stats to the log // Log writes stats to the log
func (stats RoutesStoreStats) Log() { func (stats *RoutesStoreStats) Log() {
log.Println("Routes store:") log.Println("Routes store:")
log.Println(" Routes Imported:", log.Println(" Routes Imported:",
stats.TotalRoutes.Imported, stats.TotalRoutes.Imported,
@ -65,7 +65,7 @@ type NeighborsStoreStats struct {
} }
// Log prints the stats // Log prints the stats
func (stats NeighborsStoreStats) Log() { func (stats *NeighborsStoreStats) Log() {
log.Println("Neighbors store:") log.Println("Neighbors store:")
log.Println(" Neighbors:", log.Println(" Neighbors:",

View File

@ -1,7 +0,0 @@
# Ignore static build in repo
rice-box.go
# Ignore builds
alice-lg-*

View File

@ -1,22 +0,0 @@
package backend
// Globals
var (
AliceConfig *Config
AliceRoutesStore *RoutesStore
AliceNeighborsStore *NeighborsStore
)
// InitConfig loads the configuration into the global
// AliceConfig
func InitConfig(filename string) error {
var err error
AliceConfig, err = loadConfig(filename)
return err
}
// InitStores initializes the routes and neighbors cache
func InitStores() {
AliceNeighborsStore = NewNeighborsStore(AliceConfig)
AliceRoutesStore = NewRoutesStore(AliceConfig)
}

View File

@ -1,4 +1,4 @@
package backend package http
import ( import (
"compress/gzip" "compress/gzip"

View File

@ -1,4 +1,4 @@
package backend package http
import ( import (
"net/http" "net/http"

View File

@ -1,4 +1,4 @@
package backend package http
import ( import (
"net/http" "net/http"

View File

@ -1,4 +1,4 @@
package backend package http
import ( import (
"net/http" "net/http"

View File

@ -1,4 +1,4 @@
package backend package http
import ( import (
"net/http" "net/http"

View File

@ -1,4 +1,4 @@
package backend package http
import ( import (
"net/http" "net/http"

View File

@ -1,4 +1,4 @@
package backend package http
// Improve error handling // Improve error handling
// Create api.ErrorResponses based on errors returned from server. // Create api.ErrorResponses based on errors returned from server.

View File

@ -1,4 +1,4 @@
package backend package http
import ( import (
"fmt" "fmt"

View File

@ -1,4 +1,4 @@
package backend package http
import ( import (
"fmt" "fmt"

View File

@ -1,4 +1,4 @@
package backend package http
/* /*
Paginate api routes responses Paginate api routes responses

View File

@ -1,4 +1,4 @@
package backend package http
import ( import (
"testing" "testing"

View File

@ -1,4 +1,4 @@
package backend package http
import ( import (
"net/http" "net/http"

View File

@ -1,4 +1,4 @@
package backend package http
import ( import (
"net/http" "net/http"

View File

@ -1,4 +1,4 @@
package backend package http
import ( import (
"log" "log"

View File

@ -1,4 +1,4 @@
package backend package http
import ( import (
"fmt" "fmt"

View File

@ -1,4 +1,4 @@
package backend package http
/* /*
The theme provides a method for adding customized CSS The theme provides a method for adding customized CSS

View File

@ -1,4 +1,4 @@
package backend package http
import ( import (
"io/ioutil" "io/ioutil"

View File

@ -1,4 +1,4 @@
package backend package http
import ( import (
"io" "io"

View File

@ -299,7 +299,7 @@ func (s *NeighborsStore) FilterNeighbors(
} }
// Stats exports some statistics for monitoring. // Stats exports some statistics for monitoring.
func (s *NeighborsStore) Stats() NeighborsStoreStats { func (s *NeighborsStore) Stats() *NeighborsStoreStats {
totalNeighbors := 0 totalNeighbors := 0
rsStats := []RouteServerNeighborsStats{} rsStats := []RouteServerNeighborsStats{}
@ -317,7 +317,7 @@ func (s *NeighborsStore) Stats() NeighborsStoreStats {
} }
s.RUnlock() s.RUnlock()
storeStats := NeighborsStoreStats{ storeStats := &NeighborsStoreStats{
TotalNeighbors: totalNeighbors, TotalNeighbors: totalNeighbors,
RouteServers: rsStats, RouteServers: rsStats,
} }

View File

@ -155,7 +155,7 @@ func (rs *RoutesStore) update() {
} }
// Stats calculates some store insights // Stats calculates some store insights
func (rs *RoutesStore) Stats() RoutesStoreStats { func (rs *RoutesStore) Stats() *api.RoutesStoreStats {
totalImported := 0 totalImported := 0
totalFiltered := 0 totalFiltered := 0
@ -185,7 +185,7 @@ func (rs *RoutesStore) Stats() RoutesStoreStats {
rs.RUnlock() rs.RUnlock()
// Make stats // Make stats
storeStats := RoutesStoreStats{ storeStats := &RoutesStoreStats{
TotalRoutes: RoutesStats{ TotalRoutes: RoutesStats{
Imported: totalImported, Imported: totalImported,
Filtered: totalFiltered, Filtered: totalFiltered,