Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Convert your existing class into an EM-based API

tree: 987ca2fedc

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 test
Octocat-spinner-32 .gitignore
Octocat-spinner-32 Gemfile
Octocat-spinner-32 Gemfile.lock
Octocat-spinner-32 README.markdown
Octocat-spinner-32 Rakefile
README.markdown

Apiary

Stand up simple APIs for consumption.

Usage

Apiary let's you use any existing class and turn it into an API. For instance, say you have a class like this.

class Temperature
  def c2f(val)
    Float(val) * 9 / 5 + 32
  end
end

You can convert this to an API by annotating this class with three lines.

class Temperature
  include Apiary

  version '1.0'

  get
  def c2f(val)
    Float(val) * 9 / 5 + 32
  end
end

Now, your API is complete! You can run this with Temperature.run. This will create a server on port 3000. You can hit it with

curl http://localhost:3000/1.0/c2f/23.45

And you'll get back

74.21
Something went wrong with that request. Please try again.