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
func (stats RoutesStoreStats) Log() {
func (stats *RoutesStoreStats) Log() {
log.Println("Routes store:")
log.Println(" Routes Imported:",
stats.TotalRoutes.Imported,
@ -65,7 +65,7 @@ type NeighborsStoreStats struct {
}
// Log prints the stats
func (stats NeighborsStoreStats) Log() {
func (stats *NeighborsStoreStats) Log() {
log.Println("Neighbors store:")
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 (
"compress/gzip"

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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