mirror of
https://github.com/Lore09/Tesi-Magistrale.git
synced 2025-12-19 04:14:35 +00:00
updated http provider
This commit is contained in:
@@ -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)
|
||||||
|
|||||||
@@ -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]{
|
||||||
|
|||||||
Reference in New Issue
Block a user