store routes as directories
Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
parent
0e21144529
commit
a3b84386bc
@ -6,7 +6,6 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
)
|
)
|
||||||
@ -95,18 +94,16 @@ func (s *Store) ListRoutes(ctx context.Context) ([]string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, f := range files {
|
for _, f := range files {
|
||||||
if f.IsDir() || filepath.Ext(f.Name()) != ".json" {
|
if f.IsDir() {
|
||||||
// There is extra data in the directory, ignore
|
routes = append(routes, f.Name())
|
||||||
continue
|
|
||||||
}
|
}
|
||||||
routes = append(routes, f.Name()[:len(f.Name())-5])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return routes, nil
|
return routes, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Store) routePath(name string) string {
|
func (s *Store) routePath(name string) string {
|
||||||
return path.Join(s.root, name+".json")
|
return path.Join(s.root, name, "route.json")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Store) syncRoute(r *Route) error {
|
func (s *Store) syncRoute(r *Route) error {
|
||||||
|
Reference in New Issue
Block a user