I'm working on updating my Slim API and wanted to add the ability to define the type of response for a route within the routes url. Similar to how Reddit or Rails does it where you can add a .html,.json, or .xml to a route and have that route return the proper formatted data. Below is a Reddit example of one route being able to return a json,xml, or html response by changing the ending to whatever response type.
http://www.reddit.com/r/ObjectiveC.json
Is this something I will have to do manually with middleware parsing every route or does Slim have this built in? Any help would be greatly appreciated.
Thanks
What you're looking for isn't natively available, but you might want to look at the ContentTypes Middleware in the Slim-Middleware repo. I think that'll get you close to where you need to go, although the type is detected via the content type header via \Slim\Http\Request::getMediaType.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With