REST request event handler expectations

175 views
Skip to first unread message

Adam Cameron

unread,
Jan 3, 2014, 9:26:12 AM1/3/14
to ra...@googlegroups.com
G'day:
This is based on some experimentation based on my situation detailed here: http://cfmlblog.adamcameron.me/2014/01/help-me-understand-how-rest-request.html (which is based on a CF-specific ticket I raised with Adobe). Make sure to read Adam Tuttle's response in the comments, too.

I decided to see what Railo did in a similar situation, contriving this test code: https://gist.github.com/daccfml/8238504

And then calling each request thus:

"G'day World @ {ts '2014-01-03 14:17:43'}"


MethodFailedException was thrown

So those requests are running as expected. Cool.

In the resultant log file, I get this:

"Severity","ThreadID","Date","Time","Application","Message"
"INFO","web-0","01/03/2014","14:18:55","","onApplicationStart() called"
"INFO","web-0","01/03/2014","14:18:55","","onSessionStart() called"
"INFO","web-0","01/03/2014","14:18:55","","onRequestStart() called"
"INFO","web-0","01/03/2014","14:18:55","","onRequestEnd() called"
"INFO","web-0","01/03/2014","14:19:00","","onRequestStart() called"
"INFO","web-0","01/03/2014","14:19:00","","onRequestEnd() called"

So onApplicationStart(), onSessionStart(), onRequestStart() and onRequestEnd() are called for each request. But none of onRequest(), onCfcRequest() or onError() (where applicable) are called.

Adobe's rationale as to why neither onRequest() nor onCfcRequest() are called is because a REST request is not calling the CFC directly, Which seems a bit specious to me, to be honest. But I suspect it's the rationale in Railo too?

Given that in reality the CFC is being called, even though not explicitly in the URL, does it really make sense to say "it's not being called, hence it's not a CFC request, hence onCfcRequest() doesn't get called"?

I don't see how my code should "care" via what mechanism the application server takes to arrive my code... the thing is the entry point to the request - as far as the codebase is concerned -  is the CFC, surely?

I dunno. Maybe I'm missing something. Maybe there's a precedent set in which this is predictable behaviour, and it's just a gap in my knowledge here? This is entirely possible, as I only dabble with REST services.

Cheers!

-- 
Adam

AJ Mercer

unread,
Jan 5, 2014, 7:49:28 PM1/5/14
to ra...@googlegroups.com
​added this comment to blog:

Railo, and I am guessing ACF, has a separate serverlet for handling ReST calls
RESTServlet verses CFMLServlet - see web.xml
This may explain why there are different event hooks that rare or are not fired.


--
Did you find this reply useful? Help the Railo community and add it to the Railo Server wiki at https://github.com/getrailo/railo/wiki
---
You received this message because you are subscribed to the Google Groups "Railo" group.
To view this discussion on the web visit https://groups.google.com/d/msgid/railo/94064a2d-7420-40f6-8dba-74ac642611cf%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--

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

Chris Blackwell

unread,
Jan 6, 2014, 7:42:18 AM1/6/14
to railo
if you think of it this way;

onRequest (onCFMRequest) for calls to cfm templates, onCFCRequest for direct calls to cfc's, then maybe there should be a onRestRequest method too ?

Chris


Ben Pate

unread,
May 19, 2014, 11:25:56 AM5/19/14
to ra...@googlegroups.com
+1

! function like Application.onRestRequest() would be a huge help.  I'm finding so much boilerplate code in my REST services that I'd love to move up to a higher level.  Would this be a difficult feature request?

AJ Mercer

unread,
Jul 24, 2014, 12:15:49 AM7/24/14
to ra...@googlegroups.com
Hi Railo Dev Team

Any thoughts on why onCfcRequest() is not fired for ReST calls?

Looks like onRequest() is not fired either.

If onCfcRequest() does not make sense for rest, would  onRestRequest() be possible?


I would like to intercept calls to do security checks.


On 19 May 2014 23:25, Ben Pate <ben...@gmail.com> wrote:
+1

! function like Application.onRestRequest() would be a huge help.  I'm finding so much boilerplate code in my REST services that I'd love to move up to a higher level.  Would this be a difficult feature request?

--
Did you find this reply useful? Help the Railo community and add it to the Railo Server wiki at https://github.com/getrailo/railo/wiki
---
You received this message because you are subscribed to the Google Groups "Railo" group.

Dawesi

unread,
Jul 24, 2014, 8:13:53 PM7/24/14
to ra...@googlegroups.com
Side Topic:

How would one trigger onRestRequest if you're not using Railo/CF's implementation?

aka using configuration over convention as many people prefer? aka could we configure domain/path combo in admin or this.rest config in application.cfc

Dawesi

AJ Mercer

unread,
Jul 24, 2014, 8:18:30 PM7/24/14
to ra...@googlegroups.com
There is a separate servlet for handling ReST calls - maybe it has not implemented onCfcRequest()???




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

Adam Cameron

unread,
Aug 3, 2014, 5:55:05 PM8/3/14
to ra...@googlegroups.com
Any chance of any feedback from Railo on this?

It's off my radar, but readers of my blog are asking. I'd like to be able to clarify.

Cheers.

-- 
Adam

AJ Mercer

unread,
Aug 12, 2014, 9:34:02 PM8/12/14
to ra...@googlegroups.com
Following up - any one from Railo engineering team able to comment please?



--
Did you find this reply useful? Help the Railo community and add it to the Railo Server wiki at https://github.com/getrailo/railo/wiki
---
You received this message because you are subscribed to the Google Groups "Railo" group.

For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages