Files
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"
2020-09-18 11:41:52 +08:00
"github.com/tal-tech/go-zero/zrpc"
2020-09-04 08:13:22 +08:00
)
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,
2020-09-18 11:41:52 +08:00
Transformer: transformer.NewTransformer(zrpc.MustNewClient(c.Transform)),
2020-09-04 08:13:22 +08:00
}
2020-09-01 16:04:39 +08:00
}