pegasus.lua icon indicating copy to clipboard operation
pegasus.lua copied to clipboard

Create redirect method

Open EvandroLG opened this issue 10 years ago • 1 comments

EvandroLG avatar Jul 20 '15 12:07 EvandroLG

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

geekhunger avatar May 07 '18 09:05 geekhunger