-
-
Save anonymous/3c049a0f597546237426 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Servlet | |
class EventProcessorServlet < WEBrick::HTTPServlet::AbstractServlet | |
def initialize(server, agent) | |
super server | |
@agent = agent | |
end | |
def do_POST(req, resp) | |
begin | |
@agent.process(body) | |
rescue Exception => msg | |
resp.status = 500 | |
resp['content-type'] = 'text/plain' | |
resp.body = "#{msg}\n#{req.body}" | |
end | |
resp.status = 200 | |
end | |
end | |
# in @agent | |
def process(event_json) | |
raise "No records processed" unless do_something(event_json) | |
end | |
# response.body | |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> | |
<HTML> | |
<HEAD><TITLE>Internal Server Error</TITLE></HEAD> | |
<BODY> | |
<H1>Internal Server Error</H1> | |
No records processed | |
<HR> | |
<ADDRESS> | |
WEBrick/1.3.1 (Ruby/2.2.2/2015-04-13) at | |
127.0.0.1:59255 | |
</ADDRESS> | |
</BODY> | |
</HTML> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment