18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/useless/doc/rack/transform.rb', line 18
def call(env)
unless env['useless.doc.ui']
raise 'No UI specified.'
end
response = @app.call(env)
if response[0] == 200
begin
resource = Serialization::Load.resource(response[2].first)
html = env['useless.doc.ui'].html(resource)
[200, {'Content-Type' => 'text/html'}, [html]]
rescue Oj::ParseError
[502, {'Content-Type' => 'text/plain'}, ['Documentation JSON is malformed.']]
end
else
response
end
end
|