Welcome to DU! The truly grassroots left-of-center political community where regular people, not algorithms, drive the discussions and set the standards. Join the community: Create a free account Support DU (and get rid of ads!): Become a Star Member Latest Breaking News Editorials & Other Articles General Discussion The DU Lounge All Forums Issue Forums Culture Forums Alliance Forums Region Forums Support Forums Help & Search

Website, DB, & Software Developers

Showing Original Post only (View all)

Erich Bloodaxe BSN

(14,733 posts)
Thu Nov 5, 2015, 07:27 PM Nov 2015

Help with setting up RESTful API type of setups using C under linux? [View all]

So my boss wants to update how we do some things, and he wants to setup part of the system RESTfully, but reusing most of the code we've already got, which are .cgi scripts written up in C. I've started going through and converting all of my error setup to use the HTTP errors, while dumping my output back as JSON arrays, rather than webpages.

But my cgi files are still cgi files, all sitting in the cgi directory. I can't figure out how to word my google searches to bring up what I'm trying to find out, which is how to map incoming requests, so that, for instance, a GET to www.example.com/users/12?session=34534545 goes to my user_manager.cgi script in view mode for user number 12, while a PUT to www.example.com/users/12?session=34534545 goes to it in update mode, or a POST to www.example.com/users/12/orders goes to write_order.cgi and writes up a new order for user 12.

Do I have to write up some sort of parsing script that pulls apart everything after every incoming request, figures out which script it needs to hit and then calls that script with all of the variables being sent along? Or are there (surely!) plugin modules for apache2 servers that do what I need doing, that I can just add some routing info into?

5 replies = new reply since forum marked as read
Highlight: NoneDon't highlight anything 5 newestHighlight 5 most recent replies
Latest Discussions»Retired Forums»Website, DB, & Software Developers»Help with setting up REST...»Reply #0