wasm-nats-producer-client/main.go

29 lines
773 B
Go
Raw Normal View History

2024-12-14 01:15:08 +00:00
//go:generate go run github.com/bytecodealliance/wasm-tools-go/cmd/wit-bindgen-go generate --world hello --out gen ./wit
package main
import (
2024-12-16 19:34:52 +00:00
"net/http"
"fmt"
"go.wasmcloud.dev/component/net/wasihttp"
"gitea.rebus.ninja/lore/wasm-nats-producer-client/gen/wasmcloud/messaging/handler"
2024-12-14 01:15:08 +00:00
)
func init() {
2024-12-16 19:34:52 +00:00
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")
2024-12-14 01:15:08 +00:00
}
// 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() {}