Both should return a text and not a json object to make it dynamicly

This commit is contained in:
Michael Bykovski 2017-07-11 19:40:37 +02:00
parent d3e0833913
commit 7f5d48551d
2 changed files with 10 additions and 5 deletions

View File

@ -16,7 +16,7 @@
func requestToRequestDict(requestUUID: String, request: GCDWebServerDataRequest) -> Dictionary<String, Any> {
return [
"requestId": requestUUID,
"body": request.jsonObject ?? "",
"body": request.text ?? "",
"headers": request.headers,
"method": request.method,
"path": request.url.path,

View File

@ -38,16 +38,21 @@ exports.defineManualTests = function(contentEl, createActionButton) {
webserver.onRequest(
function(request) {
console.log('Received request');
console.log('Sending response');
console.log('requestId: ', request.requestId);
console.log('body: ', request.body);
console.log('headers: ', request.headers);
console.log('path: ', request.path);
console.log('query: ', request.query);
webserver.sendResponse(
request["requestId"],
request.requestId,
{
status: 200,
headers: {
'Content-Type': 'application/json',
'Content-Type': 'text/html',
'TestHeader': 'Just a testheader'
},
body: '{"hello":"from js!"}'
body: '<html><form method="POST"><input type="text" name="bla" /><input type="submit" /></form></html>'
}
);
}