Skip to content

Commit

Permalink
[feature] Session: added a function to set the domain URL of AJAX req…
Browse files Browse the repository at this point in the history
…uests
  • Loading branch information
Frederic Ye committed Dec 4, 2012
1 parent 01b8b0e commit c87f187
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
17 changes: 16 additions & 1 deletion lib/plugins/server/session.js
Expand Up @@ -120,9 +120,12 @@ var LowLevelPingLoop = {};
throw("Error: the connexion with the server seems to be lost. Please reload"); throw("Error: the connexion with the server seems to be lost. Please reload");
} }
// Domain used for AJAX request
var domain_url = "";
function internal_ajax(settings){ function internal_ajax(settings){
if(linked_with_server){ if(linked_with_server){
settings.url = internal_url + settings.url; settings.url = domain_url + internal_url + settings.url;
if(to_register.length != 0){ if(to_register.length != 0){
var body = settings.data; var body = settings.data;
if (typeof body == 'undefined') body=""; if (typeof body == 'undefined') body="";
Expand Down Expand Up @@ -564,6 +567,10 @@ var LowLevelPingLoop = {};
} }
} }


LowLevelSession.set_domain_url = function(d) {
domain_url = d;
}

LowLevelSession.llmake = function(st, unserialize, fun_session, LowLevelSession.llmake = function(st, unserialize, fun_session,
ctx, dfun, more, concurrent) { ctx, dfun, more, concurrent) {
the_ping_loop(); the_ping_loop();
Expand Down Expand Up @@ -747,6 +754,14 @@ function set_uu(x0, x1) {
return js_void; return js_void;
} }
/**
* @register {string -> void}
*/
function set_domain_url(d) {
LowLevelSession.set_domain_url(d);
return js_void;
}
/** /**
* @register {'st, \ * @register {'st, \
(opa[option('ctx)], RPC.Json.private.native, \ (opa[option('ctx)], RPC.Json.private.native, \
Expand Down
5 changes: 5 additions & 0 deletions lib/stdlib/core/rpc/core/session.opa
Expand Up @@ -184,6 +184,11 @@ type make_at_response = option(RPC.Json.json)


Session = {{ Session = {{


/**
* Explicitely set the domain's URL used by AJAX request, no domain by default
*/
@client set_domain_url = %%Session.set_domain_url%%

/** /**
* {2 Creating sessions} * {2 Creating sessions}
*/ */
Expand Down

0 comments on commit c87f187

Please sign in to comment.