diode 1.0 → 1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/diode/server.rb +1 -0
  3. data/lib/diode/static.rb +45 -44
  4. metadata +21 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b084a1183fbd2e06a1c0f4dec2907c3f815548747c84e92a96a7dfcf55b9b226
4
- data.tar.gz: 67f3cb1edc3f30fb787bf1f4821c4927d6af9f2a69f49f24cf789e8124bf6b21
3
+ metadata.gz: a78f492d045a8ed2000597384b5bb4ccd16028be81a2e058f18d06be800e2255
4
+ data.tar.gz: 4e8d5ba6375511e05888424c042001622a00ccf9fe2fd268a48fc24ec2edbe56
5
5
  SHA512:
6
- metadata.gz: c26da0160afddfbf021741d2897a935a2ce72e852ad64193325d33c5c7c136f6dc04881738dbe26c84d2808a8b4e9794638dfa24cf5b0c98a8a68372bacec5db
7
- data.tar.gz: a80bebc9303af4eca74a1c19a2668bb7d4ff2e70db3098c332f536302ce2881b838d29e64d2578e3edfa43774f3f50f6db69507a14f484a9a7db84b06a6e8353
6
+ metadata.gz: 9d1b3c20467382e7e3dfbdc7727f0ac7ca351d89cf023777d1cb5af3681dc1570f84230360e910ef36215e2ec7ff24171482eaa7fbdc87f7f4ddc4f4210efd31
7
+ data.tar.gz: 75b9a046bd2dbe1270e32435376d4a591ac7e3a586785bf773a85ac2175836a5f6728bba623ad8e8df13e9798a5e25c0d77fc0592a603b743d2cc6d145f75da8
data/lib/diode/server.rb CHANGED
@@ -3,6 +3,7 @@ require 'time'
3
3
  require 'json'
4
4
  require 'diode/request'
5
5
  require 'diode/response'
6
+ require 'diode/static'
6
7
 
7
8
  module Diode
8
9
 
data/lib/diode/static.rb CHANGED
@@ -8,52 +8,53 @@ class Static
8
8
  end
9
9
 
10
10
  def serve(request)
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
- return Diode::Response.new(404, "<html><body>File not found</body></html>", {"Content-type" => "text/html"}) unless filepath.exist?
15
- mimetype = @@mimetypes[filepath.extname[1..-1]] || "application/octet-stream"
16
- return Diode::Response.new(200, IO.read(filepath.to_s).b, {"Content-Type"=>mimetype, "Cache-Control" => "no-cache"})
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
- @@mimetypes = {
20
- "avi" => "video/x-msvideo",
21
- "avif" => "image/avif",
22
- "css" => "text/css",
23
- "gif" => "image/gif",
24
- "htm" => "text/html",
25
- "html" => "text/html",
26
- "ico" => "image/x-icon",
27
- "jpeg" => "image/jpeg",
28
- "jpg" => "image/jpeg",
29
- "js" => "application/javascript",
30
- "json" => "application/json",
31
- "mov" => "video/quicktime",
32
- "mp4" => "video/mp4",
33
- "mpe" => "video/mpeg",
34
- "mpeg" => "video/mpeg",
35
- "mpg" => "video/mpeg",
36
- "otf" => "font/otf",
37
- "pdf" => "application/pdf",
38
- "png" => "image/png",
39
- "qt" => "video/quicktime",
40
- "rb" => "text/plain",
41
- "svg" => "image/svg+xml",
42
- "tif" => "image/tiff",
43
- "tiff" => "image/tiff",
44
- "ttc" => "font/collection",
45
- "ttf" => "font/ttf",
46
- "txt" => "text/plain",
47
- "webm" => "video/webm",
48
- "webp" => "image/webp",
49
- "woff" => "font/woff",
50
- "woff2" => "font/woff2",
51
- "xhtml" => "text/html",
52
- "xml" => "text/xml",
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
- def self.mimetypes
56
- @@mimetypes
57
- end
56
+ def self.mimetypes
57
+ @@mimetypes
58
+ end
58
59
 
59
60
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: diode
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.0'
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-20 00:00:00.000000000 Z
11
+ date: 2023-07-23 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: json
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: async-io
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -24,7 +38,11 @@ dependencies:
24
38
  - - ">="
25
39
  - !ruby/object:Gem::Version
26
40
  version: '0'
27
- description: A simple hello world gem
41
+ description: "Diode helps you to build REST application servers by providing a container
42
+ for your servlets.\n About as simple as rack but more powerful, and nowhere near
43
+ as complex as passenger, Diode has only four classes\n that make it easy to get
44
+ up and running quickly, and provides more features as you progress, but only if
45
+ you want them. "
28
46
  email: kjell@null4.net
29
47
  executables: []
30
48
  extensions: []