Note that there are some explanatory texts on larger screens.

plurals
  1. POSeparate REST JSON API server and client?
    text
    copied!<p>I'm about to create a bunch of web apps from scratch. (See <a href="http://50pop.com/code" rel="noreferrer">http://50pop.com/code</a> for overview.) I'd like for them to be able to be accessed from many different clients: front-end websites, smartphone apps, backend webservices, etc. So I really want a JSON REST API for each one.</p> <p>Also, I prefer working on the back-end, so I daydream of me keeping my focus purely on the API, and hiring someone else to make the front-end UI, whether a website, iPhone, Android, or other app.</p> <p><strong>Please help me decide which approach I should take:</strong></p> <blockquote> <h3>TOGETHER IN RAILS</h3> <p>Make a very standard Rails web-app. In the controller, do the respond_with switch, to serve either JSON or HTML. The JSON response is then my API.</p> <p><strong>Pro:</strong> Lots of precedent. Great standards &amp; many examples of doing things this way.</p> <p><strong>Con:</strong> Don't necessarily want API to be same as web app. Don't like if/then respond_with switch approach. Mixing two very different things (UI + API).</p> </blockquote> <blockquote> <h3>REST SERVER + JAVASCRIPT-HEAVY CLIENT</h3> <p>Make a JSON-only REST API server. Use Backbone or Ember.js for client-side JavaScript to access API directly, displaying templates in browser.</p> <p><strong>Pro:</strong> I love the separation of API &amp; client. Smart people say this is the way to go. Great in theory. Seems cutting-edge and exciting.</p> <p><strong>Con:</strong> Not much precedent. Not many examples of this done well. Public examples (twitter.com) feel sluggish &amp; are even switching away from this approach.</p> </blockquote> <blockquote> <h3>REST SERVER + SERVER-SIDE HTML CLIENT</h3> <p>Make a JSON-only REST API server. Make a basic HTML website client, that accesses the REST API only. Less client-side JavaScript.</p> <p><strong>Pro:</strong> I love the separation of API &amp; client. But serving plain HTML5 is quite foolproof &amp; not client-intensive.</p> <p><strong>Con:</strong> Not much precedent. Not many examples of this done well. Frameworks don't support this as well. Not sure how to approach it.</p> </blockquote> <p>Especially looking for advice from experience, not just in-theory.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload