diode 1.1 → 1.2.1
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 +48 -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: afa0bf0af528f72eb3920cc13af9ee2b5942423eb32475b0d3d406500221d1ce
|
4
|
+
data.tar.gz: a908dd25d30fb283c14890cd6a0bcee4ccbb1cbc01bccce1f9e93ca18a611543
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6060689ab753f9f3ea5303a03790b78158e665ea237c1215756dbaeb75ceebe534c2c0b96ce97d960e6e12f7147ab5b7798a770d73bc486d53a3c2d1a56a3bfd
|
7
|
+
data.tar.gz: dedaeb80985c8f514a88ce63b786f616d3102e0a5e001b3529a9777d879f7fccde2bd22c3b6bbd7973a30df30343076dada798ea5c6c6a0dac6fd1f66eab2c10
|
data/lib/diode/server.rb
CHANGED
data/lib/diode/static.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
require 'pathname'
|
2
2
|
|
3
|
+
module Diode
|
4
|
+
|
3
5
|
class Static
|
4
6
|
|
5
7
|
def initialize(docRoot=".")
|
@@ -8,52 +10,54 @@ class Static
|
|
8
10
|
end
|
9
11
|
|
10
12
|
def serve(request)
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
return Diode::Response.new(405, "Method not allowed", {"Content-type" => "text/plain"}) unless request.method == "GET"
|
14
|
+
path = Pathname.new(request.path).cleanpath.sub(request.pattern, "") # remove the leading portion matching the mount pattern
|
15
|
+
filepath = Pathname.new(File.expand_path(path, @root))
|
16
|
+
filepath = Pathname.new(File.expand_path("index.html", filepath)) if filepath.directory?
|
17
|
+
return Diode::Response.new(404, "<html><body>File not found</body></html>", {"Content-type" => "text/html"}) unless filepath.exist?
|
18
|
+
mimetype = @@mimetypes[filepath.extname[1..-1]] || "application/octet-stream"
|
19
|
+
return Diode::Response.new(200, IO.read(filepath.to_s).b, {"Content-Type"=>mimetype, "Cache-Control" => "no-cache"})
|
17
20
|
end
|
18
21
|
|
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
|
-
|
22
|
+
@@mimetypes = {
|
23
|
+
"avi" => "video/x-msvideo",
|
24
|
+
"avif" => "image/avif",
|
25
|
+
"css" => "text/css",
|
26
|
+
"gif" => "image/gif",
|
27
|
+
"htm" => "text/html",
|
28
|
+
"html" => "text/html",
|
29
|
+
"ico" => "image/x-icon",
|
30
|
+
"jpeg" => "image/jpeg",
|
31
|
+
"jpg" => "image/jpeg",
|
32
|
+
"js" => "application/javascript",
|
33
|
+
"json" => "application/json",
|
34
|
+
"mov" => "video/quicktime",
|
35
|
+
"mp4" => "video/mp4",
|
36
|
+
"mpe" => "video/mpeg",
|
37
|
+
"mpeg" => "video/mpeg",
|
38
|
+
"mpg" => "video/mpeg",
|
39
|
+
"otf" => "font/otf",
|
40
|
+
"pdf" => "application/pdf",
|
41
|
+
"png" => "image/png",
|
42
|
+
"qt" => "video/quicktime",
|
43
|
+
"rb" => "text/plain",
|
44
|
+
"svg" => "image/svg+xml",
|
45
|
+
"tif" => "image/tiff",
|
46
|
+
"tiff" => "image/tiff",
|
47
|
+
"ttc" => "font/collection",
|
48
|
+
"ttf" => "font/ttf",
|
49
|
+
"txt" => "text/plain",
|
50
|
+
"webm" => "video/webm",
|
51
|
+
"webp" => "image/webp",
|
52
|
+
"woff" => "font/woff",
|
53
|
+
"woff2" => "font/woff2",
|
54
|
+
"xhtml" => "text/html",
|
55
|
+
"xml" => "text/xml",
|
56
|
+
}
|
54
57
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
+
def self.mimetypes
|
59
|
+
@@mimetypes
|
60
|
+
end
|
58
61
|
|
59
62
|
end
|
63
|
+
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:
|
4
|
+
version: 1.2.1
|
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-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|