Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrNotFound = errors.New("user not found")
)
View Source
var StreamInterceptor = func(srv interface{}, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error { return handler(srv, &Stream{ss}) }
View Source
var UnaryInterceptor = func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{}, err error) { md, ok := metadata.FromContext(ctx) if !ok { return nil, grpc.Errorf(codes.Unauthenticated, "unauthorized") } token, ok := md["authorization"] if !ok { return nil, grpc.Errorf(codes.Unauthenticated, "unauthorized") } sess, err := authClient.Auth(context.Background(), &sessions.AuthRequest{Token: []byte(token[0])}) if err != nil { log.Print(err) return nil, grpc.Errorf(codes.Unauthenticated, err.Error()) } if !sess.Status { return nil, grpc.Errorf(codes.Unauthenticated, "unauthorized") } return handler(ctx, req) }
Functions ¶
func New ¶
func New() pb.MessageServer
Types ¶
type ConnGetter ¶
Click to show internal directories.
Click to hide internal directories.