Add .xsjs and .xsjslib as JavaScript file extension

.xsjs and .xsjslib is used to denote server-side JavaScript files in SAP
HANA XS
This commit is contained in:
Christian Theilemann
2014-06-22 15:14:46 +02:00
parent 5e797b548c
commit f92fed60f8
3 changed files with 35 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
/*
invoke endpoint by calling in a browser:
http://<hanaserveradress>:<xsengineport(usually 8000)>/<path>/<to>/<endpoint>/helloHanaMath.xsjslib?x=4&y=2
e.g.:
http://192.168.178.20:8000/geekflyer/linguist/helloHanaEndpoint.xsjs?x=4&y=2
*/
var hanaMath = $.import("./helloHanaMath.xsjslib");
var x = parseFloat($.request.parameters.get("x"));
var y = parseFloat($.request.parameters.get("y"));
var result = hanaMath.multiply(x, y);
var output = {
title: "Hello HANA XS - do some simple math",
input: {x: x, y: y},
result: result
};
$.response.contentType = "application/json";
$.response.statusCode = $.net.http.OK;
$.response.setBody(JSON.stringify(output));

View File

@@ -0,0 +1,9 @@
/* simple hana xs demo library, which can be used by multiple endpoints */
function multiply(x, y) {
return x * y;
}
function add(x, y) {
return x + y;
}