Analysis by Fractal
This commit is contained in:
parent
63432c27c8
commit
88711084e7
|
@ -1,5 +1,7 @@
|
|||
require 'sinatra'
|
||||
require 'pathname'
|
||||
require 'net/http'
|
||||
require 'uri'
|
||||
|
||||
require 'skinny'
|
||||
|
||||
|
@ -119,6 +121,18 @@ module MailCatcher
|
|||
end
|
||||
end
|
||||
|
||||
get "/messages/:id/analysis.?:format?" do
|
||||
id = params[:id].to_i
|
||||
if part = MailCatcher::Mail.message_part_html(id)
|
||||
uri = URI.parse("http://api.getfractal.com/api/v2/validate#{"/format/#{params[:format]}" if params[:format].present?}")
|
||||
response = Net::HTTP.post_form(uri, api_key: "5c463877265251386f516f7428", html: part["body"])
|
||||
content_type ".#{params[:format]}" if params[:format].present?
|
||||
body response.body
|
||||
else
|
||||
not_found
|
||||
end
|
||||
end
|
||||
|
||||
not_found do
|
||||
"<html><body><h1>No Dice</h1><p>The message you were looking for does not exist, or doesn't have content of this type.</p></body></html>"
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue