wasm-nats-producer-client/main.go
Lorenzo Venerandi 8cd67e00a2 maybe fixed
2024-12-16 20:34:52 +01:00

29 lines
773 B
Go

//go:generate go run github.com/bytecodealliance/wasm-tools-go/cmd/wit-bindgen-go generate --world hello --out gen ./wit
package main
import (
"net/http"
"fmt"
"go.wasmcloud.dev/component/net/wasihttp"
"gitea.rebus.ninja/lore/wasm-nats-producer-client/gen/wasmcloud/messaging/handler"
)
func init() {
wasihttp.HandleFunc(handleRequest)
handler.Exports.HandleMessage = handleMessage
}
func handleRequest(w http.ResponseWriter, r *http.Request) {
// get body as string
handleHttp(r.FormValue("data"))
// send response
fmt.Fprintf(w, "Message sent!\n")
}
// Since we don't run this program like a CLI, the `main` function is empty. Instead,
// we call the `handleRequest` function when an HTTP request is received.
func main() {}