init layout
This commit is contained in:
committed by
Евстигнеев Денис Сергеевич
parent
5aec0a0895
commit
fb0ad62f0e
53
handler/handlers.go
Normal file
53
handler/handlers.go
Normal file
@@ -0,0 +1,53 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"context"
|
||||
"go.unistack.org/unistack-org/pkgdash/proto/go_generate"
|
||||
|
||||
cmsstorage "go.unistack.org/cms-service/storage"
|
||||
"go.unistack.org/micro/v3"
|
||||
"go.unistack.org/micro/v3/errors"
|
||||
"go.unistack.org/unistack-org/pkgdash/config"
|
||||
"golang.org/x/mod/sumdb/storage"
|
||||
)
|
||||
|
||||
type Handler struct {
|
||||
//db *xorm.Engine
|
||||
|
||||
svc micro.Service
|
||||
store storage.Storage
|
||||
}
|
||||
|
||||
func (h *Handler) ListPackage(ctx context.Context, req *go_generate.ListPackageReq, rsp *go_generate.ListPackageRsp) error {
|
||||
//TODO implement me
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (h *Handler) UpdateInfo(ctx context.Context, req *go_generate.UpdateInfoPackageRsp, rsp *go_generate.UpdateInfoPackageReq) error {
|
||||
//TODO implement me
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (h *Handler) AddComment(ctx context.Context, req *go_generate.CommentRsp, rsp *go_generate.CommentReq) error {
|
||||
//TODO implement me
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
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 errors.New(config.ServiceName, "error init storage", 1)
|
||||
}
|
||||
|
||||
h.store = st
|
||||
|
||||
return nil
|
||||
}
|
Reference in New Issue
Block a user