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

Allow setting unquoted or custom flags on add_headers #1249

Merged
merged 3 commits into from
Oct 20, 2018
Merged
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
Next Next commit
Allow setting unquoted on add_headers
itbm committed Oct 1, 2018
commit 7d1e75b5317ca35624e5f539a576f735ab6baa58
8 changes: 8 additions & 0 deletions templates/server/locations/headers.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
<%- @add_header.keys.sort.each do |key| -%>
Copy link
Member

Choose a reason for hiding this comment

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

I do wonder if we should also rewrite this to @add_header.sort.each do |header, value|. I think that's the same but leads to cleaner code

<%- if @add_header[key] -%>
<%- if @add_header[key].is_a?(Hash) -%>
<%- @add_header[key].each do |sk, sv| -%>
add_header "<%= key %>" <% if sk != '' %>"<%= sk %>"<% end %> <%= sv %>;
<%- end -%>
<%- else -%>
add_header "<%= key %>" "<%= @add_header[key] %>";
<%- end -%>
<%- end -%>
<%- end -%>
8 changes: 8 additions & 0 deletions templates/server/server_header.erb
Original file line number Diff line number Diff line change
@@ -117,7 +117,15 @@ server {
<% end -%>
<% if @add_header -%>
<%- @add_header.keys.sort.each do |key| -%>
Copy link
Member

Choose a reason for hiding this comment

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

Could we include the templates/server/locations/headers.erb template here to avoid duplication?

<%- if @add_header[key] -%>
<%- if @add_header[key].is_a?(Hash) -%>
<%- @add_header[key].each do |sk, sv| -%>
add_header "<%= key %>" <% if sk != '' %>"<%= sk %>"<% end %> <%= sv %>;
<%- end -%>
<%- else -%>
add_header "<%= key %>" "<%= @add_header[key] %>";
<%- end -%>
<%- end -%>
<%- end -%>
<% end -%>
<% if @maintenance -%>
8 changes: 8 additions & 0 deletions templates/server/server_ssl_header.erb
Original file line number Diff line number Diff line change
@@ -146,6 +146,14 @@ server {
<% end -%>
<% if @add_header -%>
Copy link
Member

Choose a reason for hiding this comment

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

<%- @add_header.keys.sort.each do |key| -%>
Copy link
Member

Choose a reason for hiding this comment

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

And here

<%- if @add_header[key] -%>
<%- if @add_header[key].is_a?(Hash) -%>
<%- @add_header[key].each do |sk, sv| -%>
add_header "<%= key %>" <% if sk != '' %>"<%= sk %>"<% end %> <%= sv %>;
<%- end -%>
<%- else -%>
add_header "<%= key %>" "<%= @add_header[key] %>";
<%- end -%>
<%- end -%>
<%- end -%>
<% end -%>