diode 1.1 → 1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/diode/server.rb +1 -0
- data/lib/diode/static.rb +45 -44
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a78f492d045a8ed2000597384b5bb4ccd16028be81a2e058f18d06be800e2255
|
4
|
+
data.tar.gz: 4e8d5ba6375511e05888424c042001622a00ccf9fe2fd268a48fc24ec2edbe56
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d1b3c20467382e7e3dfbdc7727f0ac7ca351d89cf023777d1cb5af3681dc1570f84230360e910ef36215e2ec7ff24171482eaa7fbdc87f7f4ddc4f4210efd31
|
7
|
+
data.tar.gz: 75b9a046bd2dbe1270e32435376d4a591ac7e3a586785bf773a85ac2175836a5f6728bba623ad8e8df13e9798a5e25c0d77fc0592a603b743d2cc6d145f75da8
|
data/lib/diode/server.rb
CHANGED
data/lib/diode/static.rb
CHANGED
@@ -8,52 +8,53 @@ class Static
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def serve(request)
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
11
|
+
return Diode::Response.new(405, "Method not allowed", {"Content-type" => "text/plain"}) unless request.method == "GET"
|
12
|
+
path = Pathname.new(request.path).cleanpath.sub(request.pattern, "") # remove the leading portion matching the mount pattern
|
13
|
+
filepath = Pathname.new(File.expand_path(path, @root))
|
14
|
+
filepath = Pathname.new(File.expand_path("index.html", filepath)) if filepath.directory?
|
15
|
+
return Diode::Response.new(404, "<html><body>File not found</body></html>", {"Content-type" => "text/html"}) unless filepath.exist?
|
16
|
+
mimetype = @@mimetypes[filepath.extname[1..-1]] || "application/octet-stream"
|
17
|
+
return Diode::Response.new(200, IO.read(filepath.to_s).b, {"Content-Type"=>mimetype, "Cache-Control" => "no-cache"})
|
17
18
|
end
|
18
19
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
20
|
+
@@mimetypes = {
|
21
|
+
"avi" => "video/x-msvideo",
|
22
|
+
"avif" => "image/avif",
|
23
|
+
"css" => "text/css",
|
24
|
+
"gif" => "image/gif",
|
25
|
+
"htm" => "text/html",
|
26
|
+
"html" => "text/html",
|
27
|
+
"ico" => "image/x-icon",
|
28
|
+
"jpeg" => "image/jpeg",
|
29
|
+
"jpg" => "image/jpeg",
|
30
|
+
"js" => "application/javascript",
|
31
|
+
"json" => "application/json",
|
32
|
+
"mov" => "video/quicktime",
|
33
|
+
"mp4" => "video/mp4",
|
34
|
+
"mpe" => "video/mpeg",
|
35
|
+
"mpeg" => "video/mpeg",
|
36
|
+
"mpg" => "video/mpeg",
|
37
|
+
"otf" => "font/otf",
|
38
|
+
"pdf" => "application/pdf",
|
39
|
+
"png" => "image/png",
|
40
|
+
"qt" => "video/quicktime",
|
41
|
+
"rb" => "text/plain",
|
42
|
+
"svg" => "image/svg+xml",
|
43
|
+
"tif" => "image/tiff",
|
44
|
+
"tiff" => "image/tiff",
|
45
|
+
"ttc" => "font/collection",
|
46
|
+
"ttf" => "font/ttf",
|
47
|
+
"txt" => "text/plain",
|
48
|
+
"webm" => "video/webm",
|
49
|
+
"webp" => "image/webp",
|
50
|
+
"woff" => "font/woff",
|
51
|
+
"woff2" => "font/woff2",
|
52
|
+
"xhtml" => "text/html",
|
53
|
+
"xml" => "text/xml",
|
54
|
+
}
|
54
55
|
|
55
|
-
|
56
|
-
|
57
|
-
|
56
|
+
def self.mimetypes
|
57
|
+
@@mimetypes
|
58
|
+
end
|
58
59
|
|
59
60
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: diode
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '1.
|
4
|
+
version: '1.2'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kjell Koda
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-07-
|
11
|
+
date: 2023-07-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|