Skip to content

mlctrez/goapp-natsws

Repository files navigation

natsws

A go-app component and proxy to allow nats client connections from a go-app application.

This was written for a very specific use case to connect to the same host:port as the go-app backend.

Don't use this if you need:

  • Fail-over requirements provided by the default client.
  • Support for jwt tokens or other security in the default client.

This repository contains an example go-app application at goapp to demonstrate how to use the component and the proxy.

See root.go for component usage, demo.go for interacting with nats, and service.go for configuration of the proxy.

To run the demo application, change the working directory to goapp-natsws/internal and issue a make command to build and run the demo application. By default, the application will run on port 8080 which can be changed in the Makefile.

The first release used nats.InProcessServer to make the connection to the websocket proxy which is still the default.

If the environment UseDialer is set, a nats.CustomDialer will be used instead. This environment must also be present in the app.Handler environment for the client to pick it up.

If the backend urls returned from Manager begin with http or https, then the Proxy will use httputil.ReverseProxy and the websocket handshake will occur in the nats codebase.

Go Report Card

created by tigwen

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published