africas-talking #50
@ -1,13 +1,15 @@
|
|||||||
package handlers
|
package handlers
|
||||||
lash marked this conversation as resolved
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"git.defalsify.org/vise.git/engine"
|
"io"
|
||||||
"git.defalsify.org/vise.git/resource"
|
|
||||||
"git.defalsify.org/vise.git/persist"
|
"git.defalsify.org/vise.git/db"
|
||||||
"git.defalsify.org/vise.git/db"
|
"git.defalsify.org/vise.git/engine"
|
||||||
|
"git.defalsify.org/vise.git/persist"
|
||||||
|
"git.defalsify.org/vise.git/resource"
|
||||||
|
|
||||||
"git.grassecon.net/urdt/ussd/internal/storage"
|
|
||||||
"git.grassecon.net/urdt/ussd/internal/handlers/ussd"
|
"git.grassecon.net/urdt/ussd/internal/handlers/ussd"
|
||||||
|
"git.grassecon.net/urdt/ussd/internal/storage"
|
||||||
)
|
)
|
||||||
|
|
||||||
type BaseSessionHandler struct {
|
type BaseSessionHandler struct {
|
||||||
@ -88,6 +90,25 @@ func(f *BaseSessionHandler) Output(rqs RequestSession) (RequestSession, error)
|
|||||||
return rqs, err
|
return rqs, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (f *BaseSessionHandler) AtOutput(rqs RequestSession) (RequestSession, error) {
|
||||||
|
var err error
|
||||||
|
var prefix string
|
||||||
|
|
||||||
|
if rqs.Continue {
|
||||||
|
prefix = "CON "
|
||||||
|
} else {
|
||||||
|
prefix = "END "
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = io.WriteString(rqs.Writer, prefix)
|
||||||
|
if err != nil {
|
||||||
|
return rqs, err
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = rqs.Engine.WriteResult(rqs.Ctx, rqs.Writer)
|
||||||
|
return rqs, err
|
||||||
|
}
|
||||||
|
|
||||||
func(f *BaseSessionHandler) Reset(rqs RequestSession) (RequestSession, error) {
|
func(f *BaseSessionHandler) Reset(rqs RequestSession) (RequestSession, error) {
|
||||||
defer f.provider.Put(rqs.Config.SessionId, rqs.Storage)
|
defer f.provider.Put(rqs.Config.SessionId, rqs.Storage)
|
||||||
return rqs, rqs.Engine.Finish()
|
return rqs, rqs.Engine.Finish()
|
||||||
|
@ -51,6 +51,7 @@ type RequestHandler interface {
|
|||||||
GetEngine(cfg engine.Config, rs resource.Resource, pe *persist.Persister) engine.Engine
|
GetEngine(cfg engine.Config, rs resource.Resource, pe *persist.Persister) engine.Engine
|
||||||
Process(rs RequestSession) (RequestSession, error)
|
Process(rs RequestSession) (RequestSession, error)
|
||||||
Output(rs RequestSession) (RequestSession, error)
|
Output(rs RequestSession) (RequestSession, error)
|
||||||
|
AtOutput(rs RequestSession) (RequestSession, error)
|
||||||
Reset(rs RequestSession) (RequestSession, error)
|
Reset(rs RequestSession) (RequestSession, error)
|
||||||
Shutdown()
|
Shutdown()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user
It would be better to have this PR against my async branch, because here we cannot see the differences....
I've updated the PR to reflect this