| // Copyright 2015 The Vanadium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style |
| // license that can be found in the LICENSE file. |
| // LeafDispatcher returns a dispatcher for a single object obj, using |
| // ReflectInvokerOrDie to invoke methods. Lookup only succeeds on the empty |
| // suffix. The provided auth is returned for successful lookups. |
| func LeafDispatcher(obj interface{}, auth security.Authorizer) rpc.Dispatcher { |
| return &leafDispatcher{rpc.ReflectInvokerOrDie(obj), auth} |
| type leafDispatcher struct { |
| func (d leafDispatcher) Lookup(suffix string) (interface{}, security.Authorizer, error) { |
| return nil, nil, verror.New(verror.ErrUnknownSuffix, nil, suffix) |
| return d.invoker, d.auth, nil |