2019-10-07 08:14:47 -06:00
|
|
|
// Copyright (c) Mainflux
|
2018-08-26 13:15:48 +02:00
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
2018-05-10 23:53:25 +02:00
|
|
|
package grpc
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/go-kit/kit/endpoint"
|
|
|
|
"github.com/mainflux/mainflux/users"
|
|
|
|
context "golang.org/x/net/context"
|
|
|
|
)
|
|
|
|
|
|
|
|
func identifyEndpoint(svc users.Service) endpoint.Endpoint {
|
|
|
|
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
|
|
|
req := request.(identityReq)
|
|
|
|
if err := req.validate(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
id, err := svc.Identify(req.token)
|
|
|
|
if err != nil {
|
|
|
|
return identityRes{}, err
|
|
|
|
}
|
|
|
|
return identityRes{id, nil}, nil
|
|
|
|
}
|
|
|
|
}
|