Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

A basic Grape API mounted on RACK.

  • Loading branch information...
commit f998058cc34c03ad8b035a64799b44359937f538 0 parents
@dblock authored
6 Gemfile
@@ -0,0 +1,6 @@
+source "http://rubygems.org"
+
+gem "rack", "1.3.5"
+gem "rack-contrib", :git => "https://github.com/rack/rack-contrib.git", :require => "rack/contrib"
+gem "grape", :git => "http://github.com/intridea/grape.git", :branch => "frontier"
+
36 Gemfile.lock
@@ -0,0 +1,36 @@
+GIT
+ remote: http://github.com/intridea/grape.git
+ revision: 6d8793f0f6cb3146f7b4c5d56fccbdfbe3ac9875
+ branch: frontier
+ specs:
+ grape (0.1.5)
+ hashie (~> 1.2)
+ multi_json
+ multi_xml
+ rack
+ rack-mount
+
+GIT
+ remote: https://github.com/rack/rack-contrib.git
+ revision: af3663ca6200f8292b221acd5a406af33c219249
+ specs:
+ rack-contrib (1.1.0)
+ rack (>= 0.9.1)
+
+GEM
+ remote: http://rubygems.org/
+ specs:
+ hashie (1.2.0)
+ multi_json (1.0.4)
+ multi_xml (0.4.1)
+ rack (1.3.5)
+ rack-mount (0.8.3)
+ rack (>= 1.0.0)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ grape!
+ rack (= 1.3.5)
+ rack-contrib!
5 README.md
@@ -0,0 +1,5 @@
+Grape API on Rack
+=================
+
+A [Grape](http://github.com/intridea/grape) API mounted on RACK.
+
19 api/api.rb
@@ -0,0 +1,19 @@
+
+module Acme
+
+ class API < Grape::API
+
+ version 'v1', :using => :header, :vendor => 'acme', :format => :json
+
+ resource :system do
+
+ desc "Returns pong."
+ get :ping do
+ "pong"
+ end
+
+ end
+
+ end
+end
+
8 config.ru
@@ -0,0 +1,8 @@
+require File.expand_path('../config/environment', __FILE__)
+
+use Rack::TryStatic,
+ :root => File.expand_path('../public', __FILE__),
+ :urls => %w[/], :try => ['.html', 'index.html', '/index.html']
+
+run Acme::API
+
6 config/application.rb
@@ -0,0 +1,6 @@
+require File.expand_path('../boot', __FILE__)
+
+Bundler.require :default, ENV['RACK_ENV']
+
+require File.expand_path('../../api/api', __FILE__)
+
3  config/boot.rb
@@ -0,0 +1,3 @@
+require 'rubygems'
+require 'bundler/setup'
+
4 config/environment.rb
@@ -0,0 +1,4 @@
+ENV['RACK_ENV'] ||= :test
+
+require File.expand_path('../application', __FILE__)
+
1  public/images/index.html
@@ -0,0 +1 @@
+This folder contains images.
BIN  public/images/rack-logo.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 public/index.html
@@ -0,0 +1,15 @@
+<html>
+ <head>
+ <title>Rack Powers Web APIs</title>
+ </head>
+ <body>
+ <h1>Rack Powers Web APIs</h1>
+ <a href="http://rack.rubyforge.org/">
+ <img src="images/rack-logo.png">
+ </a>
+ <ul>
+ <li><a href="/system/ping">Ping!</a></li>
+ </ul>
+ </body>
+</html>
+
Please sign in to comment.
Something went wrong with that request. Please try again.