Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added add_headers() method to request objects #543

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
added add_header() method to request object
  • Loading branch information
DarkWiiPlayer committed May 12, 2017
commit da12424550cd0435151f8a07f0ffbc6372f38c48
1 change: 1 addition & 0 deletions docs/actions.md
Original file line number Diff line number Diff line change
@@ -394,6 +394,7 @@ Additionally the request object has the following methods:
* `url_for(route, params, ...)` -- get the URL for a named route, or object
* `build_url(path, params)` -- build a fully qualified URL from a path and parameters
* `html(fn)` -- generate a string using the HTML builder syntax
* `add_headers(headers)` -- Adds response headers

### @req

7 changes: 7 additions & 0 deletions lapis/request.lua
Original file line number Diff line number Diff line change
@@ -104,6 +104,13 @@ do
self.buffer = { }
self.params = { }
self.options = { }
local _ = {
[self.add_headers] = function(self, headers)
for k, v in pairs(headers) do
self.res:add_header(k, v)
end
end
}
self.__class.support.load_cookies(self)
return self.__class.support.load_session(self)
end,
3 changes: 3 additions & 0 deletions lapis/request.moon
Original file line number Diff line number Diff line change
@@ -155,6 +155,9 @@ class Request
@buffer = {} -- output buffer
@params = {}
@options = {}
@add_headers: (headers) =>
for k,v in pairs headers
@res\add_header k,v

@@support.load_cookies @
@@support.load_session @