From bbfefefe3c9a2b69c49ae381c2d803bd0efc9ec9 Mon Sep 17 00:00:00 2001 From: Christine Dodrill Date: Sat, 2 Dec 2017 18:00:13 -0800 Subject: [PATCH] internal/{database,server}: use ID instead of host --- internal/database/boltdb.go | 6 +++--- internal/database/storage.go | 2 +- internal/server/route.go | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/database/boltdb.go b/internal/database/boltdb.go index 9c47728..fa6531d 100644 --- a/internal/database/boltdb.go +++ b/internal/database/boltdb.go @@ -52,11 +52,11 @@ var ( ) // GetRoute gets a single route out of the database. -func (b *BoltDBStorage) GetRoute(ctx context.Context, host string) (Route, error) { +func (b *BoltDBStorage) GetRoute(ctx context.Context, id string) (Route, error) { r := Route{} - err := b.db.One("Hostname", host, &r) + err := b.db.One("ID", id, &r) if err != nil { - ln.Error(ctx, err, ln.Action("get route"), ln.F{"host": host}) + ln.Error(ctx, err, ln.Action("get route"), ln.F{"id": id}) switch err { case storm.ErrNotFound: diff --git a/internal/database/storage.go b/internal/database/storage.go index 1470064..27de07d 100644 --- a/internal/database/storage.go +++ b/internal/database/storage.go @@ -9,7 +9,7 @@ import ( // Storage is the parent interface for the database backends of route. type Storage interface { // routes - GetRoute(ctx context.Context, host string) (Route, error) + GetRoute(ctx context.Context, id string) (Route, error) GetAllRoutes(ctx context.Context, user string) ([]Route, error) PutRoute(ctx context.Context, domain, kind string) (Route, error) DeleteRoute(ctx context.Context, id string) error diff --git a/internal/server/route.go b/internal/server/route.go index c30c6a8..26fb803 100644 --- a/internal/server/route.go +++ b/internal/server/route.go @@ -24,9 +24,9 @@ func (r *Route) Get(ctx context.Context, req *proto.GetRouteRequest) (*proto.Rou return nil, handleError(ctx, clitok, err, ln.F{"action": "Route.Get_getAuth"}) } - val, err := r.db.GetRoute(ctx, req.Host) + val, err := r.db.GetRoute(ctx, req.Id) if err != nil { - return nil, handleError(ctx, clitok, err, ln.F{"action": "get single route from database", "host": req.Host}) + return nil, handleError(ctx, clitok, err, ln.F{"action": "get single route from database", "id": req.Id}) } if val.Creator != clitok.Owner {