diff --git a/server/server.go b/server/server.go index 515da85..e3ff824 100644 --- a/server/server.go +++ b/server/server.go @@ -1,6 +1,7 @@ package server import ( + "io/ioutil" "net/http" "strings" "time" @@ -70,8 +71,11 @@ func handleMsg(ctx lib.Context, cfg *mhSpec, gc *gin.Context) { head := strings.Split(gc.Param("msg"), "/")[1:] cctx := ctx.ChildContext(cfg) msg := message.New(head...).WithSender(cctx) - // if gc.Request.Method == "POST" && data != "": msg.WithPayload(data) - logging.DebugM(cctx, msg).Msg("server.handleMessage") + if body, _ := ioutil.ReadAll(gc.Request.Body); len(body) > 0 { + pl := message.PayloadFromJson[lib.Data](string(body)) + msg.WithPayload(pl) + } + logging.DebugM(cctx, msg).Msg("server.handleMsg") var proc msgProc for _, act := range action.Select(cctx, msg) { act.Handle() diff --git a/tests/etc/etc.go b/tests/etc/etc.go index 71cb82e..4126745 100644 --- a/tests/etc/etc.go +++ b/tests/etc/etc.go @@ -26,8 +26,6 @@ func Config() lib.Config { } app_c.AddAction("demo", action.Base(action.Forward, "test-receiver")) - //server_amh := server.MsgHandler() - //server_amh.AddActionProc("demo", server.Async, "test-receiver") server_c := b("server", server.Start( (&server.Cfg{Port: ovr("8123", SERVER_PORT)}). AddRoute("/docs", server.FileServer("html")).