-
Notifications
You must be signed in to change notification settings - Fork 4
/
config.ru
27 lines (23 loc) · 756 Bytes
/
config.ru
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
require 'cloudkit'
# Test-mode-only datastore reset middleware
# Clears store on POST to /test_reset
class TestResetMiddleware
def initialize(app)
@app = app
end
def call(env)
if match_route?(env)
CloudKit.storage_adapter.clear
[200, {'Content-Type' => 'text/html', 'Content-Length' => '2'}, ['OK']]
else
@app.call(env)
end
end
def match_route?(env)
env['PATH_INFO'] == '/test_reset' && env['REQUEST_METHOD'] == 'POST'
end
end
expose :notes, :things # host RESTful "notes" and "things" JSON APIs
use TestResetMiddleware
use Rack::Static, :urls => ['/'] # serve the plugin and test files
run lambda { |env| [404, {'Content-Type' => 'text/html', 'Content-Length' => '9'}, ['Not Found']] } # appease rack