SinatraAPI.rb – a one script REST API Server in Ruby

Now for some code

The Gist below is a work in progress.  The goal is “A REST API Server in one script”.  It’s just for learning purposes, not a serious effort.

This version has:

  1. Resource model is a simple hash of Person objects, representing a team of three people to start with.  No data mappers yet.
  2. It supports all four CRUD verbs – POST, GET, PUT, DELETE respectively.  Each should return a decent HTTP response code!
  3. You can read the API with a browser or curl, but I use curl for the POST, PUT and DELETE.  The API root has examples for you to copy and paste.
  4. It has a basic X-Api-Version response header.
  5. There’s no oauth nor any integration with any backend systems yet.

So, not much, but it achieves the goal so far so whatchagonnado?

Post a Comment

Your email is kept private. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>