forked from urdt/ussd
Http server harness
Add storage retrieval solution for http handler Successfully executed account regisration using http Set upstream go-vise dependency version in go.mod Adapt menuhandler to upstream
This commit is contained in:
@@ -66,21 +66,17 @@ type Handlers struct {
|
||||
accountService server.AccountServiceInterface
|
||||
}
|
||||
|
||||
func NewHandlers(parser *asm.FlagParser, pe *persist.Persister, userdataStore db.Db) (*Handlers, error) {
|
||||
userDb := utils.UserDataStore{
|
||||
Db: userdataStore,
|
||||
}
|
||||
if pe == nil {
|
||||
return nil, fmt.Errorf("cannot create handler with nil persister")
|
||||
}
|
||||
func NewHandlers(appFlags *asm.FlagParser, userdataStore db.Db) (*Handlers, error) {
|
||||
if userdataStore == nil {
|
||||
return nil, fmt.Errorf("cannot create handler with nil userdata store")
|
||||
}
|
||||
userDb := &utils.UserDataStore{
|
||||
Db: userdataStore,
|
||||
}
|
||||
h := &Handlers{
|
||||
pe: pe,
|
||||
userdataStore: &userDb,
|
||||
flagManager: parser,
|
||||
accountService: &server.AccountService{},
|
||||
userdataStore: userDb,
|
||||
flagManager: appFlags,
|
||||
accountService: &server.AccountService{},
|
||||
}
|
||||
return h, nil
|
||||
}
|
||||
@@ -94,6 +90,14 @@ func isValidPIN(pin string) bool {
|
||||
return match
|
||||
}
|
||||
|
||||
func (h *Handlers) WithPersister(pe *persist.Persister) *Handlers {
|
||||
if h.pe != nil {
|
||||
panic("persister already set")
|
||||
}
|
||||
h.pe = pe
|
||||
return h
|
||||
}
|
||||
|
||||
func (h *Handlers) Init(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
||||
var r resource.Result
|
||||
|
||||
|
||||
Reference in New Issue
Block a user