- clone the gist
bundle install
bundle exec rackup
- visit http://localhost:9292 and http://localhost:9292/moar
-
-
Save brennovich/b98205fce18da3e104dd to your computer and use it in GitHub Desktop.
Mount Grape API at rails root
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Thanks to http://thesmallestrailsapp.com/ | |
Bundler.require | |
# Your grape API | |
class API < Grape::API | |
get { "Hello from Grape" } | |
get "/moar" do | |
"Moar" | |
end | |
end | |
run TheSmallestRailsApp ||= Class.new(Rails::Application) { | |
config.secret_key_base = routes.append { | |
mount API => "/" # This will handle "/moar" and others | |
root to: API # This will handle the root path "/" | |
}.to_s | |
initialize! | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source "http://rubygems.org" | |
gem "railties", '4.0.3', require: %w(action_controller rails) | |
gem "grape" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment