mirror of
https://github.com/appium/appium.git
synced 2026-10-28 04:14:00 +08:00
* Rename 'mjsonwp' to 'protocol' * Renamed folder from 'mjsonwp' to 'protocol' in `lib/` and `test/` * Renamed 'mjsonwp.js' to 'protocol.js' * Renamed any import statements that use 'mjsonwp' * _Possible breaking change_: MJSONWireProtocol class exposed in index was renamed to just Protocol.... checked Appium repo and found no libraries that use MJSONWireProtocol * Lint fix
25 lines
594 B
JavaScript
25 lines
594 B
JavaScript
import Express from 'express';
|
|
import bodyParser from 'body-parser';
|
|
|
|
export function createProxyServer (sessionId, port) {
|
|
// Start an express server for proxying
|
|
let app = new Express();
|
|
app.use(bodyParser.json());
|
|
let server = app.listen(port);
|
|
return {app, server};
|
|
}
|
|
|
|
let handlers = {
|
|
post: {},
|
|
get: {},
|
|
delete: {},
|
|
put: {},
|
|
};
|
|
|
|
export function addHandler (app, method, url, handler) {
|
|
method = method.toLowerCase();
|
|
if (!handlers[method][url]) {
|
|
app[method](url, (req, res) => handlers[method][url].call(this, req, res));
|
|
}
|
|
handlers[method][url] = handler;
|
|
} |