Search This Blog

Showing posts with label shared. Show all posts
Showing posts with label shared. Show all posts

Tuesday, 14 May 2013

Shared javascripts-libs in flows

If you are doing a lot of validations, transformations or response-parsing you will very fast recognize that you need sometimes the same code on different routes or steps.

How about using shared javascript libaries?

Just create a javascript file with some functions like following and save it to a javascript file "sharedlib":

"sharedlib":
// sets request parameters
function setrequest(){
    request.method = 'GET';
    request.headers['Content-Type'] = 'text/html';
    request.body = "";
}

// sets the query param "fun" to given argument
function hello(message){
    request.queryParams["fun"]=message;
}


and include it in your javascript step like shown below and you are able to use this function in your normal javascript file.

"normaljsscript":
// some things you do here and then
setrequest();
hello("world");


I found no documentation about "IncludeURL" - thats a way to use it.