cms-template/handler/handler.go
Vasiliy Tolstov 973f9ac822
Some checks failed
build / test (push) Failing after 5s
build / lint (push) Failing after 6s
initial import
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-09-26 19:45:39 +03:00

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
}