updated http provider

This commit is contained in:
2025-03-10 22:58:51 +01:00
parent edc7c1144d
commit e75fb0792e
2 changed files with 12 additions and 7 deletions

View File

@@ -8,7 +8,7 @@ def handle_task(task, output_dir):
try: try:
match task['type']: match task['type']:
case 'producer_nats': case 'http_producer_nats':
__generate_producer(task, output_dir) __generate_producer(task, output_dir)
case 'processor_nats': case 'processor_nats':
__generate_processor(task, output_dir) __generate_processor(task, output_dir)

View File

@@ -4,6 +4,7 @@ package main
import ( import (
"fmt" "fmt"
"net/http" "net/http"
"io"
logger "gitea.rebus.ninja/lore/wasm-nats-producer-client/gen/wasi/logging/logging" logger "gitea.rebus.ninja/lore/wasm-nats-producer-client/gen/wasi/logging/logging"
"gitea.rebus.ninja/lore/wasm-nats-producer-client/gen/wasmcloud/messaging/consumer" "gitea.rebus.ninja/lore/wasm-nats-producer-client/gen/wasmcloud/messaging/consumer"
@@ -30,14 +31,18 @@ func init() {
func handleHttp(w http.ResponseWriter, r *http.Request) { func handleHttp(w http.ResponseWriter, r *http.Request) {
// get body as string value, err := io.ReadAll(r.Body)
if handleRequest(r.FormValue("data")) {
fmt.Fprintf(w, "Message sent!\n") if err != nil {
} else { fmt.Fprintf(w, "Error, invalid request body\n")
fmt.Fprintf(w, "Error\n") return
} }
// send response if handleRequest(string(value)) {
fmt.Fprintf(w, "Message sent!\n")
} else {
fmt.Fprintf(w, "Error, coudln't send message\n")
}
} }
func handleMessage(msg types.BrokerMessage) cm.Result[string, struct{}, string]{ func handleMessage(msg types.BrokerMessage) cm.Result[string, struct{}, string]{