Chromium Code Reviews| Index: appengine/logdog/coordinator/endpoints/logs/service.go |
| diff --git a/appengine/logdog/coordinator/endpoints/logs/service.go b/appengine/logdog/coordinator/endpoints/logs/service.go |
| index 88f43c05d9a45f4124269be0727b9234bb204388..cda99e29400f4badf6787c95f4d098db711aea2f 100644 |
| --- a/appengine/logdog/coordinator/endpoints/logs/service.go |
| +++ b/appengine/logdog/coordinator/endpoints/logs/service.go |
| @@ -6,7 +6,12 @@ package logs |
| import ( |
| "github.com/golang/protobuf/proto" |
| + "github.com/luci/luci-go/appengine/logdog/coordinator" |
| + "github.com/luci/luci-go/appengine/logdog/coordinator/endpoints" |
| "github.com/luci/luci-go/common/api/logdog_coordinator/logs/v1" |
| + "github.com/luci/luci-go/common/config" |
| + "github.com/luci/luci-go/common/grpcutil" |
| + log "github.com/luci/luci-go/common/logging" |
| "golang.org/x/net/context" |
| ) |
| @@ -28,6 +33,22 @@ func newService(svr *server) logdog.LogsServer { |
| return &logdog.DecoratedLogs{ |
| Service: svr, |
| Prelude: func(c context.Context, methodName string, req proto.Message) (context.Context, error) { |
| + // Enter a datastore namespace based on the message type. |
| + // |
| + // We use a type switch here because this is a shared decorator. All user |
| + // mesages must implement ProjectBoundMessage. |
| + pbm, ok := req.(endpoints.ProjectBoundMessage) |
| + if !ok { |
| + log.Fields{ |
| + "methodName": methodName, |
| + }.Errorf(c, "Request (%T) does not expose a project namespace.", req) |
| + return nil, grpcutil.Internal |
| + } |
| + |
| + if err := coordinator.WithProjectNamespace(&c, config.ProjectName(pbm.GetMessageProject())); err != nil { |
| + return nil, grpcutil.Internal |
|
Ryan Tseng
2016/04/28 20:45:29
log err?
dnj
2016/04/30 02:58:02
The call should do that for me.
|
| + } |
| + |
| return c, nil |
| }, |
| } |