Application variables in REST app in lucee and application.cfc

Hi,

I am using coldfusion for years now but I am still in the old way of coding
with the application.cfm and the tag version of the code … (yeah I know,
I am playing the old guy but it’s from the jeremy allaire old time).

I am puting together an API REST with lucee … and I am not able to set
any application variables … getting stuck on this is just upsetting me so
bad …

so I have an application.cfc with that kind of code :

component output=“false”
{
this.name = “apirest”;//RestAPI
this.applicationTimeout = createTimespan(0,2,0,0);
this.restsettings.skipCFCWithError = true;

this.nom0='bonjour0'; //debug test
variables.nom1='bonjour1'; //debug test
application.nom2='bonjour2'; //debug test

public function onApplicationStart()
{
    writeLog(file="apilog", text="Lancement REST API");
    this.nom0_b='bonjour0_onappstart';
    variables.nom1_b='bonjour1_onappstart';
    application.ipgranted = "195.258.70.167";
    application.logname = "api";
    application.logname_error = "api_error";
    return true;
}

public function onApplicationEnd()
{
    writeLog(file="apilog", text="FIN REST API");
    return;
}

public boolean function onRequestStart()
{
    writeLog(file="apilog", text="Request START");
    return true;
}

public void function onError(e){
    writeLog(file="api_error", text="#GetFunctionCalledName()# called 

avec #serialize(e)#");
writeDump(var=e, label=“ERROR”);
abort;
}
}

and I have just this in a test.cfc file :

component restpath="/test" rest=“true” displayname=“get test”{
remote any function get_test(numeric id restargsource=“Path”) httpmethod
=“GET” restpath="{id}" {

    dump(application);
    dump(variables);
    dump(super);
    dump(REQUEST);
    return;

}

}

an if I call the test page with a GET :

http://api.distrigame.com/api/1.0/test/1

(I did change REST by API in the server.xml page)
it display the variables but I see nowhere any of the variables I set !
none of them …

whats wrong ???

Stéphane

Looks like you have missed a few steps
Here are some notes I started on
http://webonix.net/page/tutorials/rest-tutorial

Some pointers
The URL for will always start with /rest (or as defined in server.xml)
Then the the rest application mapping - set up in Lucee admin or with
http://docs.lucee.org/reference/functions/restinitapplication.html

Then the path to the resource

So will be something like
/rest/api/test/1

If you want a version number in the URLs add it to restpath- most likely on
the componentOn Friday, 23 October 2015, Stéphane MERLE <@Stephane_MERLE> wrote:

Hi,

I am using coldfusion for years now but I am still in the old way of
coding with the application.cfm and the tag version of the code … (yeah
I know, I am playing the old guy but it’s from the jeremy allaire old time).

I am puting together an API REST with lucee … and I am not able to set
any application variables … getting stuck on this is just upsetting me so
bad …

so I have an application.cfc with that kind of code :

component output=“false”
{
this.name = “apirest”;//RestAPI
this.applicationTimeout = createTimespan(0,2,0,0);
this.restsettings.skipCFCWithError = true;

this.nom0='bonjour0'; //debug test
variables.nom1='bonjour1'; //debug test
application.nom2='bonjour2'; //debug test

public function onApplicationStart()
{
    writeLog(file="apilog", text="Lancement REST API");
    this.nom0_b='bonjour0_onappstart';
    variables.nom1_b='bonjour1_onappstart';
    application.ipgranted = "195.258.70.167";
    application.logname = "api";
    application.logname_error = "api_error";
    return true;
}

public function onApplicationEnd()
{
    writeLog(file="apilog", text="FIN REST API");
    return;
}

public boolean function onRequestStart()
{
    writeLog(file="apilog", text="Request START");
    return true;
}

public void function onError(e){
    writeLog(file="api_error", text="#GetFunctionCalledName()# called

avec #serialize(e)#");
writeDump(var=e, label=“ERROR”);
abort;
}
}

and I have just this in a test.cfc file :

component restpath="/test" rest=“true” displayname=“get test”{
remote any function get_test(numeric id restargsource=“Path”)
httpmethod=“GET” restpath="{id}" {

    dump(application);
    dump(variables);
    dump(super);
    dump(REQUEST);
    return;

}

}

an if I call the test page with a GET :

http://api.distrigame.com/api/1.0/test/1

(I did change REST by API in the server.xml page)
it display the variables but I see nowhere any of the variables I set !
none of them …

whats wrong ???

Stéphane


See Lucee at CFCamp Oct 22 & 23 2015 @ Munich Airport, Germany - Get your
ticket NOW - http://www.cfcamp.org/

You received this message because you are subscribed to the Google Groups
“Lucee” group.
To unsubscribe from this group and stop receiving emails from it, send an
email to lucee+unsubscribe@googlegroups.com
<javascript:_e(%7B%7D,‘cvml’,‘lucee%2Bunsubscribe@googlegroups.com’);>.
To post to this group, send email to lucee@googlegroups.com
<javascript:_e(%7B%7D,‘cvml’,‘lucee@googlegroups.com’);>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/lucee/277bd4d5-f6f0-4a08-b22b-25714f7ad9f8%40googlegroups.com
https://groups.google.com/d/msgid/lucee/277bd4d5-f6f0-4a08-b22b-25714f7ad9f8%40googlegroups.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.

AJ Mercer
<webonix:net strength=“Industrial” /> http://webonix.net | <webonix:org
community=“Open” /> http://webonix.org
http://twitter.com/webonix

Sorry I missed your answer …

I did manage it to work just by restarting lucee on both nodes. It
triggered the application restart and reload the application variables.

this part of code doesn’t do it :
if (structKeyExists(url, “refreshRestServices”) or structKeyExists(url,
“reset”))
{

restInitApplication(getDirectoryFromPath(getCurrentTemplatePath()),
this.name);
}

Thanks
StéphaneLe dimanche 25 octobre 2015 01:18:29 UTC+2, AJ Mercer a écrit :

Looks like you have missed a few steps
Here are some notes I started on
http://webonix.net/page/tutorials/rest-tutorial

Some pointers
The URL for will always start with /rest (or as defined in server.xml)
Then the the rest application mapping - set up in Lucee admin or with
http://docs.lucee.org/reference/functions/restinitapplication.html

Then the path to the resource

So will be something like
/rest/api/test/1

If you want a version number in the URLs add it to restpath- most likely
on the component

On Friday, 23 October 2015, Stéphane MERLE <stephan...@gmail.com <javascript:>> wrote:

Hi,

I am using coldfusion for years now but I am still in the old way of
coding with the application.cfm and the tag version of the code … (yeah
I know, I am playing the old guy but it’s from the jeremy allaire old time).

I am puting together an API REST with lucee … and I am not able to set
any application variables … getting stuck on this is just upsetting me so
bad …

so I have an application.cfc with that kind of code :

component output=“false”
{
this.name = “apirest”;//RestAPI
this.applicationTimeout = createTimespan(0,2,0,0);
this.restsettings.skipCFCWithError = true;

this.nom0='bonjour0'; //debug test
variables.nom1='bonjour1'; //debug test
application.nom2='bonjour2'; //debug test

public function onApplicationStart()
{
    writeLog(file="apilog", text="Lancement REST API");
    this.nom0_b='bonjour0_onappstart';
    variables.nom1_b='bonjour1_onappstart';
    application.ipgranted = "195.258.70.167";
    application.logname = "api";
    application.logname_error = "api_error";
    return true;
}

public function onApplicationEnd()
{
    writeLog(file="apilog", text="FIN REST API");
    return;
}

public boolean function onRequestStart()
{
    writeLog(file="apilog", text="Request START");
    return true;
}

public void function onError(e){
    writeLog(file="api_error", text="#GetFunctionCalledName()# 

called avec #serialize(e)#");
writeDump(var=e, label=“ERROR”);
abort;
}
}

and I have just this in a test.cfc file :

component restpath="/test" rest=“true” displayname=“get test”{
remote any function get_test(numeric id restargsource=“Path”)
httpmethod=“GET” restpath="{id}" {

    dump(application);
    dump(variables);
    dump(super);
    dump(REQUEST);
    return;

}

}

an if I call the test page with a GET :

http://api.distrigame.com/api/1.0/test/1

(I did change REST by API in the server.xml page)
it display the variables but I see nowhere any of the variables I set !
none of them …

whats wrong ???

Stéphane


See Lucee at CFCamp Oct 22 & 23 2015 @ Munich Airport, Germany - Get your
ticket NOW - http://www.cfcamp.org/

You received this message because you are subscribed to the Google Groups
“Lucee” group.
To unsubscribe from this group and stop receiving emails from it, send an
email to lucee+unsubscribe@googlegroups.com.
To post to this group, send email to lucee@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/lucee/277bd4d5-f6f0-4a08-b22b-25714f7ad9f8%40googlegroups.com
https://groups.google.com/d/msgid/lucee/277bd4d5-f6f0-4a08-b22b-25714f7ad9f8%40googlegroups.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.

AJ Mercer
<webonix:net strength=“Industrial” /> http://webonix.net | <webonix:org
community=“Open” /> http://webonix.org
http://twitter.com/webonix

it is defined in web.xml

RestServlet /rest/*

you can change it to whatever you like

A separate mapping is required because a different servlet handles ReST
callsOn 2 November 2015 at 12:00, Dawesi <@Christopher_Dawes> wrote:

why CFML people insist on using /rest for the url astounds me. no-one does
that in the real world but cfml engines…

Can someone tell me where this odd behaviour comes from?

Dawesi

On Sunday, 25 October 2015 10:18:29 UTC+11, AJ Mercer wrote:

Looks like you have missed a few steps
Here are some notes I started on
http://webonix.net/page/tutorials/rest-tutorial

Some pointers
The URL for will always start with /rest (or as defined in server.xml)
Then the the rest application mapping - set up in Lucee admin or with
http://docs.lucee.org/reference/functions/restinitapplication.html

Then the path to the resource

So will be something like
/rest/api/test/1

If you want a version number in the URLs add it to restpath- most likely
on the component

On Friday, 23 October 2015, Stéphane MERLE stephan...@gmail.com wrote:

Hi,

I am using coldfusion for years now but I am still in the old way of
coding with the application.cfm and the tag version of the code … (yeah
I know, I am playing the old guy but it’s from the jeremy allaire old time).

I am puting together an API REST with lucee … and I am not able to set
any application variables … getting stuck on this is just upsetting me so
bad …

so I have an application.cfc with that kind of code :

component output=“false”
{
this.name = “apirest”;//RestAPI
this.applicationTimeout = createTimespan(0,2,0,0);
this.restsettings.skipCFCWithError = true;

this.nom0='bonjour0'; //debug test
variables.nom1='bonjour1'; //debug test
application.nom2='bonjour2'; //debug test

public function onApplicationStart()
{
    writeLog(file="apilog", text="Lancement REST API");
    this.nom0_b='bonjour0_onappstart';
    variables.nom1_b='bonjour1_onappstart';
    application.ipgranted = "195.258.70.167";
    application.logname = "api";
    application.logname_error = "api_error";
    return true;
}

public function onApplicationEnd()
{
    writeLog(file="apilog", text="FIN REST API");
    return;
}

public boolean function onRequestStart()
{
    writeLog(file="apilog", text="Request START");
    return true;
}

public void function onError(e){
    writeLog(file="api_error", text="#GetFunctionCalledName()#

called avec #serialize(e)#");
writeDump(var=e, label=“ERROR”);
abort;
}
}

and I have just this in a test.cfc file :

component restpath="/test" rest=“true” displayname=“get test”{
remote any function get_test(numeric id restargsource=“Path”)
httpmethod=“GET” restpath="{id}" {

    dump(application);
    dump(variables);
    dump(super);
    dump(REQUEST);
    return;

}

}

an if I call the test page with a GET :

http://api.distrigame.com/api/1.0/test/1

(I did change REST by API in the server.xml page)
it display the variables but I see nowhere any of the variables I set !
none of them …

whats wrong ???

Stéphane


See Lucee at CFCamp Oct 22 & 23 2015 @ Munich Airport, Germany - Get
your ticket NOW - http://www.cfcamp.org/

You received this message because you are subscribed to the Google
Groups “Lucee” group.
To unsubscribe from this group and stop receiving emails from it, send
an email to lucee+unsubscribe@googlegroups.com.
To post to this group, send email to lucee@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/lucee/277bd4d5-f6f0-4a08-b22b-25714f7ad9f8%40googlegroups.com
https://groups.google.com/d/msgid/lucee/277bd4d5-f6f0-4a08-b22b-25714f7ad9f8%40googlegroups.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.

AJ Mercer
<webonix:net strength=“Industrial” /> http://webonix.net | <webonix:org
community=“Open” /> http://webonix.org
http://twitter.com/webonix


You received this message because you are subscribed to the Google Groups
“Lucee” group.
To unsubscribe from this group and stop receiving emails from it, send an
email to lucee+unsubscribe@googlegroups.com.
To post to this group, send email to lucee@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/lucee/a7fbd127-b1d5-49f0-8024-d3aaebbc188b%40googlegroups.com
https://groups.google.com/d/msgid/lucee/a7fbd127-b1d5-49f0-8024-d3aaebbc188b%40googlegroups.com?utm_medium=email&utm_source=footer
.

For more options, visit https://groups.google.com/d/optout.

AJ Mercer
<webonix:net strength=“Industrial” /> http://webonix.net | <webonix:org
community=“Open” /> http://webonix.org
http://twitter.com/webonix

why CFML people insist on using /rest for the url astounds me. no-one does
that in the real world but cfml engines…

Can someone tell me where this odd behaviour comes from?

DawesiOn Sunday, 25 October 2015 10:18:29 UTC+11, AJ Mercer wrote:

Looks like you have missed a few steps
Here are some notes I started on
http://webonix.net/page/tutorials/rest-tutorial

Some pointers
The URL for will always start with /rest (or as defined in server.xml)
Then the the rest application mapping - set up in Lucee admin or with
http://docs.lucee.org/reference/functions/restinitapplication.html

Then the path to the resource

So will be something like
/rest/api/test/1

If you want a version number in the URLs add it to restpath- most likely
on the component

On Friday, 23 October 2015, Stéphane MERLE <stephan...@gmail.com <javascript:>> wrote:

Hi,

I am using coldfusion for years now but I am still in the old way of
coding with the application.cfm and the tag version of the code … (yeah
I know, I am playing the old guy but it’s from the jeremy allaire old time).

I am puting together an API REST with lucee … and I am not able to set
any application variables … getting stuck on this is just upsetting me so
bad …

so I have an application.cfc with that kind of code :

component output=“false”
{
this.name = “apirest”;//RestAPI
this.applicationTimeout = createTimespan(0,2,0,0);
this.restsettings.skipCFCWithError = true;

this.nom0='bonjour0'; //debug test
variables.nom1='bonjour1'; //debug test
application.nom2='bonjour2'; //debug test

public function onApplicationStart()
{
    writeLog(file="apilog", text="Lancement REST API");
    this.nom0_b='bonjour0_onappstart';
    variables.nom1_b='bonjour1_onappstart';
    application.ipgranted = "195.258.70.167";
    application.logname = "api";
    application.logname_error = "api_error";
    return true;
}

public function onApplicationEnd()
{
    writeLog(file="apilog", text="FIN REST API");
    return;
}

public boolean function onRequestStart()
{
    writeLog(file="apilog", text="Request START");
    return true;
}

public void function onError(e){
    writeLog(file="api_error", text="#GetFunctionCalledName()# 

called avec #serialize(e)#");
writeDump(var=e, label=“ERROR”);
abort;
}
}

and I have just this in a test.cfc file :

component restpath="/test" rest=“true” displayname=“get test”{
remote any function get_test(numeric id restargsource=“Path”)
httpmethod=“GET” restpath="{id}" {

    dump(application);
    dump(variables);
    dump(super);
    dump(REQUEST);
    return;

}

}

an if I call the test page with a GET :

http://api.distrigame.com/api/1.0/test/1

(I did change REST by API in the server.xml page)
it display the variables but I see nowhere any of the variables I set !
none of them …

whats wrong ???

Stéphane


See Lucee at CFCamp Oct 22 & 23 2015 @ Munich Airport, Germany - Get your
ticket NOW - http://www.cfcamp.org/

You received this message because you are subscribed to the Google Groups
“Lucee” group.
To unsubscribe from this group and stop receiving emails from it, send an
email to lucee+unsubscribe@googlegroups.com.
To post to this group, send email to lucee@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/lucee/277bd4d5-f6f0-4a08-b22b-25714f7ad9f8%40googlegroups.com
https://groups.google.com/d/msgid/lucee/277bd4d5-f6f0-4a08-b22b-25714f7ad9f8%40googlegroups.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.

AJ Mercer
<webonix:net strength=“Industrial” /> http://webonix.net | <webonix:org
community=“Open” /> http://webonix.org
http://twitter.com/webonix