Sha256: 047e4288615fc75e90443d0dfbb2b6734979486736b3b1c860ac0cdc513e29e8
Contents?: true
Size: 1.3 KB
Versions: 5
Compression:
Stored size: 1.3 KB
Contents
require 'erb' require 'hako/front' module Hako module Fronts class Nginx < Front def generate_config(app_port) listen_spec = "app:#{app_port}" ERB.new(File.read(nginx_conf_erb), nil, '-').result(binding) end private def templates_directory File.expand_path('../../templates', __FILE__) end def nginx_conf_erb File.join(templates_directory, 'nginx.conf.erb') end def nginx_location_conf_erb File.join(templates_directory, 'nginx.location.conf.erb') end def locations locs = extra.fetch('locations', {}).dup locs['/'] ||= {} locs.keys.each do |k| locs[k] = Location.new(locs[k]) end locs end def client_max_body_size extra.fetch('client_max_body_size', nil) end def render_location(listen_spec, location) ERB.new(File.read(nginx_location_conf_erb), nil, '-').result(binding).each_line.map do |line| " #{line}" end.join('') end class Location def initialize(config) @config = config end def allow_only_from allow = @config.fetch('allow_only_from', nil) if allow allow.flatten end end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
hako-0.7.0 | lib/hako/fronts/nginx.rb |
hako-0.6.1 | lib/hako/fronts/nginx.rb |
hako-0.6.0 | lib/hako/fronts/nginx.rb |
hako-0.5.1 | lib/hako/fronts/nginx.rb |
hako-0.5.0 | lib/hako/fronts/nginx.rb |