Class: Configuration::OutputDataURIImage
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from OutputImage
#initialize, parse
Class Method Details
.match(node) ⇒ Object
169
170
171
|
# File 'lib/httpimagestore/configuration/output.rb', line 169
def self.match(node)
node.name == 'output_data_uri_image'
end
|
Instance Method Details
#realize(request_state) ⇒ Object
173
174
175
176
177
178
179
180
181
182
|
# File 'lib/httpimagestore/configuration/output.rb', line 173
def realize(request_state)
image = request_state.images[@name]
fail "image '#{@name}' needs to be identified first to be used in data URI output" unless image.mime_type
cache_control = @cache_control
request_state.output do
res['Cache-Control'] = cache_control if cache_control
write 200, 'text/uri-list', "data:#{image.mime_type};base64,#{Base64.strict_encode64(image.data)}"
end
end
|