-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.rb
37 lines (29 loc) · 949 Bytes
/
app.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem 'rails'
gem 'rack'
gem 'puma'
end
require 'rack'
require 'rack/handler/puma'
# In config/application.rb, normally we require rails/all
# Instead, we'll only require what we need:
require 'action_controller/railtie'
class TinyApp < Rails::Application
config.eager_load = true # necessary to silence warning
config.api_only = true # removes middleware we dont need
config.logger = Logger.new($stdout)
Rails.logger = config.logger
config.secret_key_base = ENV['SECRET_KEY_BASE'] # Rails won't boot w/o a secret token for session, cookies, etc.
routes.append { get '/welcome' => 'welcome#show' }
end
class WelcomeController < ActionController::Base
def show
render json: { message: 'Hello' }
end
end
# Initialize the app (originally in config/environment.rb)
TinyApp.initialize!
# Run it (originally in config.ru)
Rack::Handler::Puma.run TinyApp