servicecontext.go 644 B

1234567891011121314151617181920212223242526
  1. package svc
  2. import (
  3. "github.com/zeromicro/go-zero/rest"
  4. "github.com/zeromicro/go-zero/zrpc"
  5. "ylink/apis/cmd/cmd"
  6. "ylink/bff/apibff/internal/config"
  7. "ylink/bff/apibff/internal/middleware"
  8. "ylink/ext/globalkey"
  9. )
  10. type ServiceContext struct {
  11. Config config.Config
  12. CmdRpc cmd.Cmd
  13. Player2Ctx rest.Middleware
  14. }
  15. func NewServiceContext(c config.Config) *ServiceContext {
  16. globalkey.AccessSecret = c.JwtAuth.AccessSecret
  17. globalkey.AccessExpire = c.JwtAuth.AccessExpire
  18. return &ServiceContext{
  19. Config: c,
  20. CmdRpc: cmd.NewCmd(zrpc.MustNewClient(c.CmdRpc)),
  21. Player2Ctx: middleware.NewPlayer2CtxMiddleware().Handle,
  22. }
  23. }