MondayA co-worker of mine has been absolutely fighting with CF10 REST to try and make it work. It is not working. It is fundamentally broken in several ways. I'll not list them all here. But, a few are: (Adding cfdump for diagnostics causes a 500. Trying to do authorization or error handling in the Application.cfc causes a 500. Changes to any CFC in the framework folder cause a 500.) Hmmm that sure is a lot of 500s. The final straw was it's tendency to start throwing 500 errors after it's been active for a while and nothing had changed.
Monday I came in and my co-worker informed me that she would NOT launch our internal REST API using CF10 REST. I agreed. We had a number of options. None of them were great. Based on the implementations of the current CF REST frameworks, I've been considering writing my own for weeks. I told our CTO that we could NOT launch with CF10 REST and that I thought I could build a REST framework in a day. (Crazy! I know.) He told me I had permission to do it if I could do it in the next 8 hours. After we had our developer meeting and I handled some other responsibilities, I got to start work on my framework at about 12 noon.
Here are some goals I wanted to achieve:
- Write a clean lightweight framework that helped and didn't hinder you.
- NOT require you to have an Application.cfc that extends one of my CFCs
- NOT require you to write silly wrapper CFCs if you didn't need to.
- Allow you to configure your resource handlers in a nice JSON packet.
- Generally get out your way after that.
I speced the framework out. I created an epic in JIRA. I created a board named "One Day of REST" and a sprint called "Today!". I added my stories. I went and got a sugar-free Monster. I turned on some dubstep. I built my MXUnit text cfc full of failing tests. And then I wrote code and closed issues as fast as I could for the rest of the day. It was the most fun I have had for ages! I went home at 6:30pm with all my tests passing and a working demo running (and a programming high you wouldn't believe).
TuesdayThe next day I came in exhilarated and excited to hand my work off to my co-worker. I had her get latest from SVN and setup the example. While I was sitting there, we figured out the IIS URL rewrite. And she had the test running where she was going to put the final API code. I told her I was excited to see the first REST resource that she converted over and to let me know when it was done. She said, "Why don't we do it right now?". So, I said, "Sure.". After the hours and days and weeks she spent fighting CF10 REST, I watched her implement the first resource in about 48 seconds. It was amazing!
Our president walked by right about that time. My co-worker explained what was going on. He suggested we "sell" the framework to other shops. I suggested we "give" it to the community. He agreed. And thus was born "Relaxation".