Class: AdditionBehavior

Inherits:
Behavior show all
Defined in:
lib/Behavior.rb

Instance Attribute Summary

Attributes inherited from Behavior

#output_array_for_backend_resp, #output_array_for_hash, #output_array_for_recv

Instance Method Summary collapse

Methods inherited from Behavior

#delete_symbol

Constructor Details

#initialize(cache_behavior) ⇒ AdditionBehavior

defaultのbehavior以外はoriginに対してPATHが付加する



124
125
126
127
# File 'lib/Behavior.rb', line 124

def initialize(cache_behavior)
  super(cache_behavior)
  @url = cache_behavior.path_pattern
end

Instance Method Details

#store_code_for_backend_respObject



141
142
143
144
145
146
147
148
149
150
151
# File 'lib/Behavior.rb', line 141

def store_code_for_backend_resp
  # behaviorの条件
  ## PATHの条件分岐を追加
  ## origindomain/PATH もしくは origindomain/PATH?param=hoge であるurlの条件
  @output_array_for_backend_resp << "if(bereq.url ~ \"^(#{@url.gsub(/\*/, ".*")}|#{@url.gsub(/\*/, ".*")}\\?.*)\"){"
  super
  @output_array_for_backend_resp << "}"
  @output_array_for_backend_resp.each_with_index do |code_line, index|
    code_line.insert(0, "  ")
  end
end

#store_code_for_hashObject



153
154
155
156
157
158
159
160
161
162
163
164
165
# File 'lib/Behavior.rb', line 153

def store_code_for_hash
  # behaviorの条件
  ## PATHの条件分岐を追加
  ## origindomain/PATH もしくは origindomain/PATH?param=hoge であるurlの条件
  if @forward_headers.items[0] != "*"
  @output_array_for_hash << "if(req.url ~ \"^(#{@url.gsub(/\*/, ".*")}|#{@url.gsub(/\*/, ".*")}\\?.*)\"){"
  super
  @output_array_for_hash << "}"
  @output_array_for_hash.each_with_index do |code_line, index|
    code_line.insert(0, "  ")
  end
end
end

#store_code_for_recvObject



129
130
131
132
133
134
135
136
137
138
139
# File 'lib/Behavior.rb', line 129

def store_code_for_recv
  # behaviorの条件
  ## PATH PATTERN
  ## origindomain/PATH もしくは origindomain/PATH?param=hoge であるurlの条件
  @output_array_for_recv << "if(req.url ~ \"^(#{@url.gsub(/\*/, ".*")}|#{@url.gsub(/\*/, ".*")}\\?.*)\"){"
  super
  @output_array_for_recv << "}"
  @output_array_for_recv.each_with_index do |code_line, index|
    code_line.insert(0, "  ")
  end
end