forked from urdt/ussd
Fix symptom of handler missing persister
This commit is contained in:
parent
836e5fe8ee
commit
514e043e38
@ -16,7 +16,6 @@ import (
|
||||
fsdb "git.defalsify.org/vise.git/db/fs"
|
||||
gdbmdb "git.defalsify.org/vise.git/db/gdbm"
|
||||
"git.defalsify.org/vise.git/engine"
|
||||
"git.defalsify.org/vise.git/persist"
|
||||
"git.defalsify.org/vise.git/resource"
|
||||
"git.defalsify.org/vise.git/logging"
|
||||
|
||||
@ -113,12 +112,6 @@ func getResource(resourceDir string, ctx context.Context) (resource.Resource, er
|
||||
return rfs, nil
|
||||
}
|
||||
|
||||
func getEngine(cfg engine.Config, rs resource.Resource, pr *persist.Persister) *engine.DefaultEngine {
|
||||
en := engine.NewEngine(cfg, rs)
|
||||
en = en.WithPersister(pr)
|
||||
return en
|
||||
}
|
||||
|
||||
func main() {
|
||||
var dbDir string
|
||||
var resourceDir string
|
||||
@ -196,7 +189,8 @@ func main() {
|
||||
defer stateStore.Close()
|
||||
|
||||
rp := &httpserver.DefaultRequestParser{}
|
||||
sh := httpserver.NewSessionHandler(cfg, rs, stateStore, userdataStore, rp, hl.Init)
|
||||
//sh := httpserver.NewSessionHandler(cfg, rs, stateStore, userdataStore, rp, hl.Init)
|
||||
sh := httpserver.NewSessionHandler(cfg, rs, stateStore, userdataStore, rp, hl)
|
||||
s := &http.Server{
|
||||
Addr: fmt.Sprintf("%s:%s", host, strconv.Itoa(int(port))),
|
||||
Handler: sh,
|
||||
|
@ -10,6 +10,8 @@ import (
|
||||
"git.defalsify.org/vise.git/logging"
|
||||
"git.defalsify.org/vise.git/persist"
|
||||
"git.defalsify.org/vise.git/resource"
|
||||
|
||||
"git.grassecon.net/urdt/ussd/internal/handlers/ussd"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -45,15 +47,18 @@ type SessionHandler struct {
|
||||
cfgTemplate engine.Config
|
||||
rp RequestParser
|
||||
rs resource.Resource
|
||||
first resource.EntryFunc
|
||||
//first resource.EntryFunc
|
||||
hn *ussd.Handlers
|
||||
provider StorageProvider
|
||||
}
|
||||
|
||||
func NewSessionHandler(cfg engine.Config, rs resource.Resource, stateDb db.Db, userdataDb db.Db, rp RequestParser, first resource.EntryFunc) *SessionHandler {
|
||||
//func NewSessionHandler(cfg engine.Config, rs resource.Resource, stateDb db.Db, userdataDb db.Db, rp RequestParser, first resource.EntryFunc) *SessionHandler {
|
||||
func NewSessionHandler(cfg engine.Config, rs resource.Resource, stateDb db.Db, userdataDb db.Db, rp RequestParser, hn *ussd.Handlers) *SessionHandler {
|
||||
return &SessionHandler{
|
||||
cfgTemplate: cfg,
|
||||
rs: rs,
|
||||
first: first,
|
||||
//first: first,
|
||||
hn: hn,
|
||||
rp: rp,
|
||||
provider: NewSimpleStorageProvider(stateDb, userdataDb),
|
||||
}
|
||||
@ -101,9 +106,10 @@ func(f *SessionHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||
f.writeError(w, 500, "Storage retrieval fail", err)
|
||||
return
|
||||
}
|
||||
f.hn = f.hn.WithPersister(storage.Persister)
|
||||
defer f.provider.Put(cfg.SessionId, storage)
|
||||
en := getEngine(cfg, f.rs, storage.Persister)
|
||||
en = en.WithFirst(f.first)
|
||||
en = en.WithFirst(f.hn.Init)
|
||||
if cfg.EngineDebug {
|
||||
en = en.WithDebug(nil)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user