rack-mogilefs 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY.md +5 -0
- data/README.md +0 -1
- data/lib/rack/mogilefs.rb +2 -1
- data/lib/rack/mogilefs/endpoint.rb +12 -6
- metadata +10 -9
data/HISTORY.md
CHANGED
data/README.md
CHANGED
data/lib/rack/mogilefs.rb
CHANGED
@@ -15,7 +15,12 @@ module Rack
|
|
15
15
|
def call(env)
|
16
16
|
path = key_for_path(env['PATH_INFO'].dup)
|
17
17
|
data = client.get_file_data(path)
|
18
|
-
|
18
|
+
size = Utils.bytesize(data).to_s
|
19
|
+
|
20
|
+
[ 200, {
|
21
|
+
"Content-Type" => content_type(path),
|
22
|
+
"Content-Length" => size
|
23
|
+
}, [data] ]
|
19
24
|
rescue ::MogileFS::Backend::UnknownKeyError => e
|
20
25
|
[ 404, { "Content-Type" => "text/html" }, [e.message] ]
|
21
26
|
rescue ::MogileFS::UnreachableBackendError => e
|
@@ -30,11 +35,12 @@ module Rack
|
|
30
35
|
@options[:mapper].respond_to?(:call) ? @options[:mapper].call(path) : path
|
31
36
|
end
|
32
37
|
|
33
|
-
def content_type(
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
+
def content_type(path)
|
39
|
+
Mime.mime_type(::File.extname(path), @options[:default_content_type])
|
40
|
+
end
|
41
|
+
|
42
|
+
def content_length(data)
|
43
|
+
Utils.bytesize(data)
|
38
44
|
end
|
39
45
|
|
40
46
|
def client
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-mogilefs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 29
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 3
|
10
|
+
version: 0.1.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ben Marini
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-09-
|
18
|
+
date: 2010-09-10 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -35,18 +35,19 @@ dependencies:
|
|
35
35
|
type: :runtime
|
36
36
|
version_requirements: *id001
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
|
-
name:
|
38
|
+
name: rack
|
39
39
|
prerelease: false
|
40
40
|
requirement: &id002 !ruby/object:Gem::Requirement
|
41
41
|
none: false
|
42
42
|
requirements:
|
43
|
-
- - "
|
43
|
+
- - ">="
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
hash:
|
45
|
+
hash: 19
|
46
46
|
segments:
|
47
47
|
- 1
|
48
|
-
-
|
49
|
-
|
48
|
+
- 1
|
49
|
+
- 0
|
50
|
+
version: 1.1.0
|
50
51
|
type: :runtime
|
51
52
|
version_requirements: *id002
|
52
53
|
- !ruby/object:Gem::Dependency
|