Just spent an hour trying to get the REST servlet ...
# lucee
a
Just spent an hour trying to get the REST servlet to work - then I fell back on the [awesome] cfml.linen.dev to see a post explaining you have to make a commandbox setting to get it setup the routes and port. @Dean explains that CB turns if off by default - and A. Cameron classic response -
Shouldn't it "default" to "not meddling with stuff"?
Which i appreciated. Anyway back to my point - is the lucee REST servlet still the go-to option for setting up simple REST services for internal integration calls between apps? or is there something better. I only ask bc I don't see it mentioned here much, plus the commandbox default to turn it off made me wonder if anyone actually uses it.
q
I use it all the time. But also, don't use commandbox for anything.
BUT I do think I'm one of the few that does use it. I see more movement using Taffy than the native REST endpoints
👍 1
a
Thanks. I might look at taffy. I have the native stuff setup in lucee web admin and I have the commandbox setting on.. and there is zero sign of commandbox responding at all on port 8888. one [dumb] question. I assumed you could just add these REST services to an existing app (so they could leverage existing components etc.). But maybe I am missing the point - and they need to be their own isolated site with their own application.cfc ?
Just watched your Michigan UG video on YT, @quetwo. Really nice. The thing that confused me was that all the examples on the Lucee site state that the REST servlet serves the /rest mapping off of port 8888 by default. But watching your video, your /rest app was just running off of localhost port 80, alongside your CF pages. That at least got it working for me. Aside from that, I noticed that the servlet must run in its own application as none of the app vars were available. Got me up and running though. Much appreciated.
q
Thanks. If you run it on the standard Tomcat deployment, it gets deployed just like your normal website. So if you run it through IIS, Apache or Ngnyx, it would be just like the rest of your pages.
Also, a work around to the CF app not syncing with the rest of the tree, just put a application.cfc in your REST folder with the following :
Copy code
component extends="../Application"
{
    // connects this folder to main Application.cfc
}
(assuming your REST cfcs are one folder within your regular app.
a
OK. great. working now. I just tried it on my servers that don't use commandbox and they worked straightaway.. so it's all some kind of Commandbox issue that I cannot decipher. thanks so much.
e
@Anders Lars do you mean this commandbox setting? https://commandbox.ortusbooks.com/embedded-server/configuring-your-server/rest-servlet Also, I would argue that the de facto way of doing REST nowadays is via ColdBox. It’s the only framework that is actively being maintained and updated on a predefined timetable: https://coldbox.ortusbooks.com/digging-deeper/rest-handler
a
thanks - and yes that setting. After kicking the tires on the Lucee REST servlet, whilst I got it to work (and it was likely good enough for my integration needs), I decided it was very basic, required too much messing around between commandbox servers, IIS and the almost complete lack of usage of it. Plus the docs on it didn't line up with how I got it to work - in terms of ports etc. I think for internal integration purposes, Taffy is likely fine on a server that is not exposed to the outside - and I found pretty decent and whilst not an active dev repo - the contributors are still active. Noted re ColdBox being by far the best option. The issue with ColdBox is just the sheer LOE to lift a million+ lines of very old school CF code into a framework is more than I want to bite off right now.
q
Like I mentioned earlier, the Lucee REST servlet actually is pretty powerful. A bit under-documented, but nearly compatible with ACF, so it's pretty safe to use their docs for it. The biggest things it won't do is authentication and rate limiting. Auth is pretty easy to roll on your own, but rate limiting is a big leap. Since I'm in the AWS ecospace so much, I usually leave the rate limiting and auth to AWS's API gateway anyway. Lucee will fight you sometimes on return types, but usually the worst is that it sees JSON as strings and adds extra "'s to stuff. I've had 0 luck with the ColdBox Rest handler. It's also underdocumented and I've found if you are 100% into ColdBox, it's OK, but outside of that it fights you the entire way.
a
Well - this thread is exactly what I needed to figure out and I really appreciate everyone's input. My summary - 1. The Lucee servlet (as evidenced by Nick -

https://www.youtube.com/watch?v=FUrwMKN9mmU▾

) can do most of what you need. It has some minimal and somewhat confusing [to me] documentation, and possibly less active users than #2 and #3 - but it is built in to Lucee and just works. Main reason I didn't run with it was bc there were hoops for commandbox and IIS and it was going to be complicated to manage bc my environments have different architectures. 2. Taffy seems stable, more users and some really solid devs who built it - even though it is not really under an active development - but that might just be bc it does what it needs to do. Docs are decent and has samples for rate limiting and security. I assume some level of community support in the slack channel. There are some gotchas on setup just like #1. 3. ColdBox REST handler is full-featured, is [the only one that] supported and is a no-brainer if you are in the ColdBox ecosystem already.