Successfully executed account regisration using http

This commit is contained in:
lash 2024-09-06 03:05:18 +01:00
parent 350b040a59
commit 4accb847b9
Signed by: lash
GPG Key ID: 21D2E7BB88C2A746
3 changed files with 27 additions and 15 deletions

View File

@ -118,13 +118,15 @@ func main() {
var resourceDir string var resourceDir string
var size uint var size uint
var sessionId string var sessionId string
var debug bool var engineDebug bool
var stateDebug bool
var host string var host string
var port uint var port uint
flag.StringVar(&sessionId, "session-id", "075xx2123", "session id") flag.StringVar(&sessionId, "session-id", "075xx2123", "session id")
flag.StringVar(&dbDir, "dbdir", ".state", "database dir to read from") flag.StringVar(&dbDir, "dbdir", ".state", "database dir to read from")
flag.StringVar(&resourceDir, "resourcedir", path.Join("services", "registration"), "resource dir") flag.StringVar(&resourceDir, "resourcedir", path.Join("services", "registration"), "resource dir")
flag.BoolVar(&debug, "d", false, "use engine debug output") flag.BoolVar(&engineDebug, "engine-debug", false, "use engine debug output")
flag.BoolVar(&stateDebug, "state-debug", false, "use engine debug output")
flag.UintVar(&size, "s", 160, "max size of output") flag.UintVar(&size, "s", 160, "max size of output")
flag.StringVar(&host, "h", "127.0.0.1", "http host") flag.StringVar(&host, "h", "127.0.0.1", "http host")
flag.UintVar(&port, "p", 7123, "http port") flag.UintVar(&port, "p", 7123, "http port")
@ -147,18 +149,18 @@ func main() {
OutputSize: uint32(size), OutputSize: uint32(size),
FlagCount: uint32(16), FlagCount: uint32(16),
} }
if stateDebug {
cfg.StateDebug = true
}
if engineDebug {
cfg.EngineDebug = true
}
rs, err := getResource(resourceDir, ctx) rs, err := getResource(resourceDir, ctx)
if err != nil { if err != nil {
fmt.Fprintf(os.Stderr, err.Error()) fmt.Fprintf(os.Stderr, err.Error())
os.Exit(1) os.Exit(1)
} }
//
// pr, err := getPersister(dbDir, ctx)
// if err != nil {
// fmt.Fprintf(os.Stderr, err.Error())
// os.Exit(1)
// }
userdataStore := getUserdataDb(dbDir, ctx) userdataStore := getUserdataDb(dbDir, ctx)
if err != nil { if err != nil {

View File

@ -7,10 +7,15 @@ import (
"git.defalsify.org/vise.git/db" "git.defalsify.org/vise.git/db"
"git.defalsify.org/vise.git/engine" "git.defalsify.org/vise.git/engine"
"git.defalsify.org/vise.git/logging"
"git.defalsify.org/vise.git/persist" "git.defalsify.org/vise.git/persist"
"git.defalsify.org/vise.git/resource" "git.defalsify.org/vise.git/resource"
) )
var (
logg = logging.NewVanilla().WithDomain("httpserver")
)
type RequestParser struct { type RequestParser struct {
} }
@ -77,6 +82,8 @@ func(f *SessionHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
cfg := f.cfgTemplate cfg := f.cfgTemplate
cfg.SessionId = sessionId cfg.SessionId = sessionId
logg.InfoCtxf(ctx, "new request", "session", cfg.SessionId, "input", input)
storage, err := f.provider.Get(cfg.SessionId) storage, err := f.provider.Get(cfg.SessionId)
if err != nil { if err != nil {
f.writeError(w, 500, "Storage retrieval fail", err) f.writeError(w, 500, "Storage retrieval fail", err)
@ -88,9 +95,12 @@ func(f *SessionHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
en = en.WithDebug(nil) en = en.WithDebug(nil)
} }
if len(input) == 0 { r, err = en.Init(ctx)
r, err = en.Init(ctx) if err != nil {
} else { f.writeError(w, 500, "Engine init fail", err)
return
}
if r && len(input) > 0 {
r, err = en.Exec(ctx, input) r, err = en.Exec(ctx, input)
} }
if err != nil { if err != nil {

View File

@ -30,14 +30,14 @@ func NewSimpleStorageProvider(stateStore db.Db, userdataStore db.Db) StorageProv
} }
} }
func (*SimpleStorageProvider) Get(sessionId string) (Storage, error) { func (p *SimpleStorageProvider) Get(sessionId string) (Storage, error) {
return Storage{}, nil return p.Storage, nil
} }
func (*SimpleStorageProvider) Put(sessionId string, storage Storage) error { func (p *SimpleStorageProvider) Put(sessionId string, storage Storage) error {
return nil return nil
} }
func (*SimpleStorageProvider) Close() error { func (p *SimpleStorageProvider) Close() error {
return nil return nil
} }