43 lines
857 B
Go
43 lines
857 B
Go
package handler
|
|
|
|
import (
|
|
"context"
|
|
|
|
cmsstorage "go.unistack.org/cms-service/storage"
|
|
mpb "go.unistack.org/cms-template-proto"
|
|
templatepb "go.unistack.org/cms-template-proto/micro"
|
|
"go.unistack.org/cms-template/storage"
|
|
"go.unistack.org/micro/v3"
|
|
)
|
|
|
|
var _ templatepb.AccountServiceServer = (*Handler)(nil)
|
|
|
|
type Handler struct {
|
|
svc micro.Service
|
|
store storage.Storage
|
|
}
|
|
|
|
func NewHandler(svc micro.Service) *Handler {
|
|
return &Handler{svc: svc}
|
|
}
|
|
|
|
func (h *Handler) Init(ctx context.Context) error {
|
|
store := cmsstorage.InterfaceFromContext(h.svc.Options().Context)
|
|
if store == nil {
|
|
return cmsstorage.ErrMissingStorage
|
|
}
|
|
|
|
st, ok := store.(storage.Storage)
|
|
if !ok {
|
|
return cmsstorage.ErrInvalidStorage
|
|
}
|
|
|
|
h.store = st
|
|
|
|
return nil
|
|
}
|
|
|
|
func (h *Handler) Call(ctx context.Context, req *mpb.CallReq, rsp *mpb.CallRsp) error {
|
|
return nil
|
|
}
|