Closed jufickel closed 9 years ago
The RequestHandler will not know what the URL to the newly created resource is, you must program that yourself.
You can get the current request URI via self.request.uri
though https://turbo.readthedocs.org/en/latest/httpserver.html#httprequest-class.
I see. Thanks. What remains unclear to me is how to interleave turbo.web.Application
and HTTPServer
since I'm writing a REST application with the core web framework.
Like this you mean? There are a lot of examples in the /examples directory of the project.
local turbo = require "turbo"
local ExampleHandler = class("ExampleHandler", turbo.web.RequestHandler)
function ExampleHandler:get()
self:write("Hello World!")
end
local app = turbo.web.Application({
{"^/$", ExampleHandler},
-- Serve contents of directory.
{"^/(.*)$", turbo.web.StaticFileHandler, "/var/www/"}
})
local srv = turbo.httpserver.HTTPServer(app)
srv:bind(8888)
srv:start(1) -- Adjust amount of processes to fork.
turbo.ioloop.instance():start()
Yes that was what I was looking for. Now everything works as expected. Thank you very much!
Hi,
I would like to set the
Location
header in the response of a POST request. According to the HTTP spec this header should contain an absolute URI to the newly created resource (or entity). Now I'm trying to obtain the absolute URI somehow within the RequestHandler of the POST request. Could you please inform me about how to achieve this?Thank you!