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

Added add_headers() method to request objects #543

wants to merge 3 commits into from

Conversation

DarkWiiPlayer
Copy link
Contributor

@DarkWiiPlayer DarkWiiPlayer commented May 12, 2017

Why?

Because sometimes you may want to set headers progressively instead of just having one long header table at the end of your code. Specially useful when setting defaults in before-filters (UTF-8, spoofing the server, adding a lapis version header, etc.)

How?

By just adding a simple method that calls the add_header method of the response object (see code)

Example

app:before_filter(function(self)	
	self:add_headers {
		content_type = "text/html; charset=utf-8";
		lapis_version = require "lapis.version";
		server = "Super Secret, even if you knew you wouldn't find any vulnerabilities on google!"
	}
end)

I also couldn't resist removing a line of code that did absolutely nothing (again, see code)

@DarkWiiPlayer
Copy link
Contributor Author

I have no idea why that was a : instead of a =, but it is fixed now (I've said this before, but I don't moonscript)

@@ -155,7 +155,7 @@ class Request
@buffer = {} -- output buffer
@params = {}
@options = {}
@add_headers: (headers) =>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This mistake is probably a side-effect of writing too much CSS during the days leading up to this commit

@DarkWiiPlayer
Copy link
Contributor Author

@leafo I just remembered this pull request and noticed it's still open. Am I supposed to do something more, like a feature request ticked?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant