Skip to content

Commit

Permalink
#1 Add second example project URLs
Browse files Browse the repository at this point in the history
The backend does not yet work as wanted. We need to fix #6 first.
  • Loading branch information
Thomas Rosenau committed Apr 14, 2016
1 parent 995b420 commit 3fe5585
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 7 deletions.
6 changes: 5 additions & 1 deletion src/example2/config/services/GET.mock.development.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@
"active": true,
"services": [
{
"active": true,
"path": "exampleEndpoint",
"file": "get-result.example.json"
}, {
"path": "mix-n-mock",
"error": {
"status": 500
}
}
]
}
29 changes: 24 additions & 5 deletions src/example2/example2-public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
}

button {
width: 15em;
width: 30em;
height: 2em;
text-align: center;
}
Expand Down Expand Up @@ -71,29 +71,48 @@ <h2>Advanced example</h2>
<a href="img/example.by.Marcelo.Quinan.from.unsplash.com-CC-zero.jpg" target="_blank">static file</a>
<ul>
<li>
<button type="submit" data-method="GET" data-action="rest/exampleEndpoint">
<button type="submit" data-method="GET" data-action="exampleEndpoint">
Submit GET-Request
</button>
<span>(no delay)</span>
</li>
<li>
<button type="submit" data-method="POST" data-action="rest/exampleEndpoint">
<button type="submit" data-method="POST" data-action="exampleEndpoint">
Submit POST-Request
</button>
<span>(100ms delay)</span>
</li>
<li>
<button type="submit" data-method="PUT" data-action="rest/exampleEndpoint">
<button type="submit" data-method="PUT" data-action="exampleEndpoint">
Submit PUT-Request
</button>
<span>(1s delay)</span>
</li>
<li>
<button type="submit" data-method="DELETE" data-action="rest/exampleEndpoint">
<button type="submit" data-method="DELETE" data-action="exampleEndpoint">
Submit DELETE-Request
</button>
<span>(5s delay)</span>
</li>
<li>
<button type="submit" data-method="GET" data-action="repos/SEITENBAU/mix-n-mock">
Get mix-n-mock repo info from Github
</button>
<span>(proxied)</span>
</li>
<li>
<button type="submit" data-method="GET" data-action="repos/github/github-services">
Get github/github-services repo info from Github
</button>
<span>(proxied)</span>
</li>
<li>
<button type="submit" data-method="GET" data-action="repos/mix-n-mock">
Get repos/mix-n-mock
</button>
<span>(simulated error)</span>
</li>

</ul>
<div class="hidden">
<div class="result"></div>
Expand Down
3 changes: 2 additions & 1 deletion src/lib/routing.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const express = require('express');
const request = require('request');
const fileExists = require('file-exists');
const path = require('path');
const url = require('url');

const getFilePath = require('./helpers/getFilePath');

Expand Down Expand Up @@ -154,7 +155,7 @@ let setup = (expressWare, roots, paths, localProxyConfig, serverProxyConfig, pro
*/
let pipeRequest = (requestConfig, req, res) => {
let remote = request(Object.assign({}, requestConfig, {
url: serverProxyConfig.backend + req.url.replace(roots.serverRoot, '')
url: url.resolve(serverProxyConfig.backend, req.url.replace(roots.serverRoot, ''))
}));
req.pipe(remote);
remote.pipe(res);
Expand Down

0 comments on commit 3fe5585

Please sign in to comment.