mercredi 4 février 2015

Same functionality over different platforms

I've written an API for my mobile application and I want to create a dashboard system as well. Which will use the functionality made in the API.


As far as I know I have two (decent) options:



  • reach the api by having a subdomain like api.domain.com and just make calls to that using Guzzle (or something similar)

  • just change the data output for the specific platform (json for api, array for dashboard)


If I choose option #2. How would I keep the functionality in my classes but only change the output of the data.

What would be the best way to keep your functionality stable, but only change the output of it.


Im using Laravel, so it would be Response::json($data) or View::make('view')->withData($data).


Was thinking about making a method called response(), where I check if the request is made through an ajax call or not and return the data the right way.


What would you recommend, which would be scalable as well?


Aucun commentaire:

Enregistrer un commentaire