https://github.com/tangojs/tangojs-connector-mtango
mTango backend support for TangoJS.
https://github.com/tangojs/tangojs-connector-mtango
Last synced: about 1 year ago
JSON representation
mTango backend support for TangoJS.
- Host: GitHub
- URL: https://github.com/tangojs/tangojs-connector-mtango
- Owner: tangojs
- License: mit
- Created: 2016-04-18T16:45:48.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2018-05-22T07:08:32.000Z (about 8 years ago)
- Last Synced: 2025-04-10T13:18:44.354Z (about 1 year ago)
- Language: JavaScript
- Size: 35.2 KB
- Stars: 0
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# tangojs-connector-mtango
[mTango](https://bitbucket.org/hzgwpn/mtango/wiki/Home) backend support for
TangoJS.
## Example
The module exports single constructor function, `MTangoConnector.` Create the
connector and pass it to the `setConnector` method:
```javascript
const connector = new window.tangojs.connector.mtango.MTangoConnector(
'http://localhost:8080/mtango/rest/rc2', // endpoint
'tango', // username
'tango') // password
window.tangojs.core.setConnector(connector)
```
## 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.
1. Deploy mTango on [Apache Tomcat](https://tomcat.apache.org/download-80.cgi),
according to [these instructions](https://bitbucket.org/hzgwpn/mtango/wiki/Home#markdown-header-war).
1. 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.
1. Shutdown the container.
1. Modify `` 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:
```xml
Tango RESTful gateway
/rest/*
GET
HEAD
POST
PUT
DELETE
mtango-rest
```
1. Add servlet filter for CORS requests to `${CATALINA_HOME}conf/web.xml`
(this should also work when added to mtango-specific `web.xml`).
```xml
CorsFilter
org.apache.catalina.filters.CorsFilter
cors.allowed.methods
GET,HEAD,POST,PUT,DELETE,OPTIONS
cors.allowed.headers
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
CorsFilter
/rest/*
```