how to make redirect in webrick/ruby?

303 views Asked by At

How to make Redirect in WEBRICK Ruby, can the simplest example with the syntax?

In this example

require 'webrick'

    class MyServlet < WEBrick::HTTPServlet::AbstractServlet
        def do_GET (request, response)
                result = ""           
                case request.path
                    when "/redirect_test"
                          puts("not yet working")
                    when "/test"
                        result = " arg"
                    when "/"
                else
                result = " error"
                end
            response.body = "main"+result
        end
    end
    server = WEBrick::HTTPServer.new(:Port => 1234)
    server.mount "/", MyServlet
    server.start
0

There are 0 answers