atlas_middleware 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/decode_base64_image.rb +21 -0
- data/lib/ignore_ext_js_cache_buster.rb +0 -1
- data/lib/map_server_legend_info.rb +3 -3
- metadata +3 -2
@@ -0,0 +1,21 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'base64'
|
3
|
+
|
4
|
+
class DecodeBase64Image
|
5
|
+
def call(env)
|
6
|
+
request = Rack::Request.new(env)
|
7
|
+
content_type = request['content_type'] || 'image/png'
|
8
|
+
image_data = request['image_data']
|
9
|
+
|
10
|
+
begin
|
11
|
+
raise "Missing required parameter 'image_data'" if image_data.to_s.empty?
|
12
|
+
response = Rack::Response.new(Base64.decode64(image_data), 200, { 'Content-Type' => content_type })
|
13
|
+
# set caching information
|
14
|
+
response.headers['Cache-Control'] = "public, max-age=#{1.month}"
|
15
|
+
rescue Exception => e
|
16
|
+
response = Rack::Response.new(e.message, 500, { 'Content-Type' => 'text/plain' })
|
17
|
+
end
|
18
|
+
|
19
|
+
response.to_a
|
20
|
+
end
|
21
|
+
end
|
@@ -10,7 +10,7 @@ class MapServerLegendInfo
|
|
10
10
|
begin
|
11
11
|
response = Rack::Response.new(get_legends(request), 200, headers)
|
12
12
|
# set caching information
|
13
|
-
response.headers['Cache-Control'] = "public, max-age=#{
|
13
|
+
response.headers['Cache-Control'] = "public, max-age=#{1.month}"
|
14
14
|
rescue Exception => e
|
15
15
|
response = Rack::Response.new({ :error => e.message }.to_json, 500, headers)
|
16
16
|
end
|
@@ -21,8 +21,8 @@ class MapServerLegendInfo
|
|
21
21
|
private
|
22
22
|
def get_legends(request)
|
23
23
|
map_server = ArcServer::MapServer.new(request['url'])
|
24
|
-
|
25
|
-
legend = map_server.get_legend_info(:
|
24
|
+
image_return_url = request['image_return_url'] == 'true'
|
25
|
+
legend = map_server.get_legend_info(:image_return_url => image_return_url)
|
26
26
|
legend.to_json
|
27
27
|
end
|
28
28
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: atlas_middleware
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Colin Casey
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-11-
|
12
|
+
date: 2009-11-12 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -94,6 +94,7 @@ extra_rdoc_files:
|
|
94
94
|
files:
|
95
95
|
- lib/arcgis_server_rest_proxy.rb
|
96
96
|
- lib/cgns_search.rb
|
97
|
+
- lib/decode_base64_image.rb
|
97
98
|
- lib/export_map_services.rb
|
98
99
|
- lib/ignore_ext_js_cache_buster.rb
|
99
100
|
- lib/map_server_legend_info.rb
|