go-zero/example/shorturl/api/internal/svc/servicecontext.go

21 lines
410 B
Go
Raw Normal View History

2020-09-01 16:04:39 +08:00
package svc
2020-09-04 08:13:22 +08:00
import (
"shorturl/api/internal/config"
"shorturl/rpc/transform/transformer"
"github.com/tal-tech/go-zero/rpcx"
)
2020-09-01 16:04:39 +08:00
type ServiceContext struct {
2020-09-04 08:13:22 +08:00
Config config.Config
Transformer transformer.Transformer
2020-09-01 16:04:39 +08:00
}
func NewServiceContext(c config.Config) *ServiceContext {
2020-09-04 08:13:22 +08:00
return &ServiceContext{
Config: c,
Transformer: transformer.NewTransformer(rpcx.MustNewClient(c.Transform)),
}
2020-09-01 16:04:39 +08:00
}