You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

39 lines
1.1 KiB

package service
import (
"context"
"encoding/json"
"fmt"
user "git.diulo.com/mogfee/kit/api"
"git.diulo.com/mogfee/kit/middleware/jwt"
"git.diulo.com/mogfee/kit/transport"
)
type UserService struct {
user.UnimplementedUserServer
}
func (*UserService) Login(ctx context.Context, req *user.LoginRequest) (*user.LoginResponse, error) {
//return nil, errors.BadRequest("BadRequest", "B")
return &user.LoginResponse{Token: "182131292"}, nil
}
func (*UserService) List(ctx context.Context, req *user.LoginRequest) (*user.LoginResponse, error) {
fmt.Println(jwt.FromUserContext(ctx))
fmt.Println(jwt.FromAuthKeyContext(ctx))
tr, ok := transport.FromServerContext(ctx)
if ok {
return &user.LoginResponse{Token: tr.Operation()}, nil
}
//fmt.Println(ctx.Value("userId"))
//return nil, errors.Wrap(errors.InternalServer("InternalServer", "B"), "")
//b, _ := json.Marshal(req)
return &user.LoginResponse{Token: "123123"}, nil
}
func (*UserService) Delete(ctx context.Context, req *user.LoginRequest) (*user.LoginResponse, error) {
//return nil, errors.New("bad err")
b, _ := json.Marshal(req)
return &user.LoginResponse{Token: string(b)}, nil
}