Add-on Microservices

The Enable2020-web-server-service is the main web server. There are three different ways to add custom integrations.

  • Include routes to additional static files (.html).
  • Include routes to proxy to an external web server.
  • Include routes to another microservice queue (custom microservices).

They are described in the following sections.

Additional Static Files

You may want to add a custom web component and bring it up in a widget or add a custom popup from an attribute define button.

Your web files will be treated as part of the same application, and therefore have the same cookies. This means you can include JavaScript that makes any REST API call.

To do this, place your files in a location that can be reached by the web server process. Then add an entry in the install script as follows:

-customPaths=/custom;<install drive>:/Enterworks/custom ^

Each path is defined by two paths separated by a semicolon. The first entry is the relative path specified in the URL. The second entry is the physical path to the associated folder.

You can supply multiple paths by using a comma separator between each semicolon-delimited pair:

-customPaths=/custom1;<install drive>:/Enterworks/custom1,/custom2;<install drive>/Enterworks/custom2 ^

Proxies

Similar to additional static files, you can point a relative path URL to another web server.

Again, any JavaScript running from files served by the proxied server will have access to the REST API. Add an entry in the install script as follows:

-customProxies=/myapp1;myAppServer1:8080

Each proxy is defined by two paths separated by a semicolon. The first entry is the relative path specified in the URL. The second entry is the URL for the proxy.

For example, if you refer a widget's custom URL to /myapp1/somefile.html, then somefile.html lives on an external web server.

The proxy web server can be written in any language.

There is an example Go Language web server that can be installed as a Windows service. The example serves static files from a command line configured path. It is located at:

/enable2020-go/service-mains/example/enable2020-example-web-server-service.go

Custom Microservices

The preferred way to customize and enhance enable2020 is to write a custom microservice that receives messages from RabbitMQ.

Your microservice should define a queue on the same RabbitMQ server. The web server will capture any request on the custom queue path and send it to your custom queue.

customQueues=/custom1;myCustomQueue1,/api/custom2;customQueue2

Each microservice is defined by two paths separated by a semicolon. The first entry is the relative path specified in the URL. The second entry is the RabbitMQ queue name.

It isn't required, but your queue names should be parameterized and follow the same naming convention as the rest of the microservices.

An example of a custom microservice is provided at:

/enable2020-go/service-mains/example/enable2020-example-micro-service.go

The example is written in Golang, mainly because it is easy to install as a Windows service, however, you could use any process and language to connect to RabbitMQ and establish a queue worker.

The RabbitMQ documentation web page has examples in eleven languages including Java, JavaScript, Python, C#, and Go. The documentation is available at:

https://www.rabbitmq.com/getstarted.html

The message structure sent from the web server is like an HTTP request and has the following structure:

type EwMicroServiceMsg struct {

Method string

URI string

Body []byte

Headers string

EwToken string // Used for authentication of other microservices

}

If you POST a JSON document, it will be serialized in the Body. It's up to you to deserialize it.