Analysis by Fractal

This commit is contained in:
Samuel Cochran 2011-10-07 22:16:17 +08:00
parent 63432c27c8
commit 88711084e7
1 changed files with 14 additions and 0 deletions

View File

@ -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