https://github.com/savaki/nats-proxy

http in the front; NATS in the back

nats-proxy provides an HTTP gateway that simplifies service discovery by 
using NATS as the transport layer between services.

client --[http]--> gateway --[nats]--> service


*Start the API Gateway*

// Start the Gateway
nc, _ := nats.Connect(nats.DefaultURL)
gw, _ := nats_proxy.Wrap(h, nats_proxy.WithNats(nc))

http.ListenAndServe(":8080", gw) 

 

*Start the Service*

// Start the Service
h := http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
  io.WriteString(w, "hello world")
})

nc, _ := nats.Connect(nats.DefaultURL)
r, _ := nats_proxy.Wrap(h,
  nats_proxy.WithNats(nc),
)
r.Subscribe(context.Background())










-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to