7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/rack/restful-controller.rb', line 7
def call(env)
@request = Rack::Request.new(env)
@params = (@request.params || {}).merge(env['restful.params'])
if env['restful.action'] && respond_to?(env['restful.action'])
body = send(env['restful.action'])
case body
when String
[200, {'Content-Type' => 'text/html', 'Content-Length' => body.length.to_s}, [body]]
when Array
body
end
else
body = "Not Found: #{@request.path}"
[404, {'Content-Type' => 'text/plain', 'Content-Length' => body.length.to_s}, [body]]
end
end
|