Created
May 14, 2014 14:53
-
-
Save catharinejm/f45092e96b5f21d460b2 to your computer and use it in GitHub Desktop.
WEBrick
This file contains hidden or 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
| irb> require 'webrick' | |
| #=> true | |
| irb> server = WEBrick::HTTPServer.start :Port => 4000 | |
| #=> #<WEBrick::HTTPServer:0x007fc349081ec0 ...> | |
| irb> server.mount_proc("/foo") { |req, res| res.status = 400; res.body = "WHOOPS\n" } | |
| #=> [#<WEBrick::HTTPServlet::ProcHandler:0x007fc34a1131f8 @proc=#<Proc:0x007fc34a113248@(irb):4>>, []] | |
| irb> server.start | |
| # [2014-05-14 10:51:28] INFO WEBrick::HTTPServer#start: pid=77103 port=4000 | |
| # Meanwhile, in the shell... | |
| $ curl -i localhost:4000/foo | |
| HTTP/1.1 400 Bad Request | |
| Server: WEBrick/1.3.1 (Ruby/2.0.0/2013-06-27) | |
| Date: Wed, 14 May 2014 14:51:49 GMT | |
| Content-Length: 7 | |
| Connection: Keep-Alive | |
| WHOOPS | |
| $ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment