tangojs-connector-mtango
mTango backend support for TangoJS.
Example
The module exports single constructor function, MTangoConnector.
Create the
connector and pass it to the setConnector
method:
const connector = 'http://localhost:8080/mtango/rest/rc2' // endpoint 'tango' // username 'tango' // password windowtangojscore
Configuration
To use this connector, CORS support must be enabled in mTango. This may be
configured in your servlet container - bundled (*.jar
) version of mTango
won't work. Required steps are described below.
-
Deploy mTango on Apache Tomcat, according to these instructions.
-
Make sure everything works, e.g. you can see the list of all devices if you access
http://localhost:8080/mtango/rest/rc2/devices
in your browser. -
Shutdown the container.
-
Modify
<security-constraint>
for RESTful endpoint (declared in${CATALINA_HOME}/webapps/mtango/WEB-INF/web.xml
). The constraint shall apply to all HTTP methods except OPTIONS, which is used for CORS preflight:
- Add servlet filter for CORS requests to
${CATALINA_HOME}conf/web.xml
(this should also work when added to mtango-specificweb.xml
).
<init-param>
<param-name>cors.allowed.methods</param-name>
<param-value>GET,HEAD,POST,PUT,DELETE,OPTIONS</param-value>
</init-param>
<init-param>
<param-name>cors.allowed.headers</param-name>
<param-value>Origin,Accept,X-Requested-With,Content-Type,Access-Control-Request-Method,Access-Control-Request-Headers,Authorization,Accept-Encoding,Accept-Language,Access-Control-Request-Method,Cache-Control,Connection,Host,Referer,User-Agent</param-value>
</init-param>
CorsFilter
/rest/*
```