Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions app/acme_app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,22 @@ def initialize
:urls => %w[/]
})
end

def call(env)
request_path = env['PATH_INFO']
# static files
@filenames.each do |path|
response = @rack_static.call(env.merge({'PATH_INFO' => request_path + path}))
return response if response[0] != 404
end
# api
response = Acme::API.call(env)
# error pages

# Check if the App wants us to pass the response along to others
if response[1]['X-Cascade'] == 'pass'
# static files
request_path = env['PATH_INFO']
@filenames.each do |path|
response = @rack_static.call(env.merge({'PATH_INFO' => request_path + path}))
return response if response[0] != 404
end
end

# Serve error pages or respond with API response
case response[0]
when 404, 500
@rack_static.call(env.merge({'PATH_INFO' => "/errors/#{response[0]}.html"}))
Expand Down