EvandroLG/pegasus.lua

Create redirect method

EvandroLG opened this issue · 1 comments

Create redirect method

I need it! Is it difficult to do? Could you point me in the right direction, please?

# Edit: I tried to use HTTP redirect. Unfortunately this method only works BEFORE any :write on the client body

function Response:forward(path) -- NOTE this call must appear before any :write() otherwise it will be ignored
    self:statusCode(302)
    self.headers = {}
    self:addHeader("Location", path)
    self:sendOnlyHeaders()
    self.client:close()
    return self
end