internal/{database,server}: use ID instead of host
This commit is contained in:
parent
107d40fc87
commit
bbfefefe3c
|
@ -52,11 +52,11 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetRoute gets a single route out of the database.
|
// 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{}
|
r := Route{}
|
||||||
err := b.db.One("Hostname", host, &r)
|
err := b.db.One("ID", id, &r)
|
||||||
if err != nil {
|
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 {
|
switch err {
|
||||||
case storm.ErrNotFound:
|
case storm.ErrNotFound:
|
||||||
|
|
|
@ -9,7 +9,7 @@ import (
|
||||||
// Storage is the parent interface for the database backends of route.
|
// Storage is the parent interface for the database backends of route.
|
||||||
type Storage interface {
|
type Storage interface {
|
||||||
// routes
|
// 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)
|
GetAllRoutes(ctx context.Context, user string) ([]Route, error)
|
||||||
PutRoute(ctx context.Context, domain, kind string) (Route, error)
|
PutRoute(ctx context.Context, domain, kind string) (Route, error)
|
||||||
DeleteRoute(ctx context.Context, id string) error
|
DeleteRoute(ctx context.Context, id string) error
|
||||||
|
|
|
@ -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"})
|
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 {
|
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 {
|
if val.Creator != clitok.Owner {
|
||||||
|
|
Loading…
Reference in New Issue