agoo 1.1.2 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of agoo might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/README.md +3 -4
- data/ext/agoo/server.c +1 -2
- data/lib/agoo.rb +1 -1
- data/lib/agoo/version.rb +1 -1
- data/lib/rack/handler/agoo.rb +50 -0
- data/test/static_test.rb +1 -0
- metadata +9 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a18f59a226cbfe061c8b645fadeab626f7ba7eb7f8af017032192bf276db749
|
4
|
+
data.tar.gz: d10ec4a0c5ba7676e2298e14cee626db4794465f6b987e02b6a8c2f341eaedb5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f8fa258e15e65f91ed6d9586c0cf951dca2038c13a52e4727a94bd79bb0794574f8cb306cd7f75188a435063f19016e7b32e754ee304fc53be75ff63ab045464
|
7
|
+
data.tar.gz: 14be184ac912ff59aaf1d097a612d8cf4228d00840b7e2410b76682909a776db5c4ce6e4f3769eb34410e42e9df8eba90d1d2b5275c6fbfe0eee6593ae2a77fb
|
data/README.md
CHANGED
@@ -14,17 +14,16 @@ require 'agoo'
|
|
14
14
|
server = Agoo::Server.new(6464, 'root')
|
15
15
|
|
16
16
|
class MyHandler
|
17
|
-
def initialize
|
18
|
-
end
|
19
|
-
|
20
17
|
def call(req)
|
21
18
|
[ 200, { }, [ "hello world" ] ]
|
22
19
|
end
|
23
20
|
end
|
24
21
|
|
25
|
-
handler =
|
22
|
+
handler = MyHandler.new
|
26
23
|
server.handle(:GET, "/hello", handler)
|
27
24
|
server.start()
|
25
|
+
# To run this example type the following then go to a browser and enter a URL of localhost:6464/hello.
|
26
|
+
# ruby hello.rb
|
28
27
|
```
|
29
28
|
|
30
29
|
## Installation
|
data/ext/agoo/server.c
CHANGED
@@ -112,7 +112,7 @@ static int
|
|
112
112
|
configure(Err err, Server s, int port, const char *root, VALUE options) {
|
113
113
|
s->port = port;
|
114
114
|
s->root = strdup(root);
|
115
|
-
s->thread_cnt =
|
115
|
+
s->thread_cnt = 0;
|
116
116
|
s->running = 0;
|
117
117
|
s->listen_thread = 0;
|
118
118
|
s->con_thread = 0;
|
@@ -165,7 +165,6 @@ configure(Err err, Server s, int port, const char *root, VALUE options) {
|
|
165
165
|
*
|
166
166
|
* - *:log_dir* [_String_] directory to place log files in. If nil or empty then no log files are written.
|
167
167
|
*
|
168
|
-
|
169
168
|
* - *:log_console* [_true_|_false_] if true log entry are display on the console.
|
170
169
|
*
|
171
170
|
* - *:log_classic* [_true_|_false_] if true log entry follow a classic format. If false log entries are JSON.
|
data/lib/agoo.rb
CHANGED
data/lib/agoo/version.rb
CHANGED
@@ -0,0 +1,50 @@
|
|
1
|
+
|
2
|
+
require 'agoo'
|
3
|
+
|
4
|
+
module Rack
|
5
|
+
module Handler
|
6
|
+
|
7
|
+
# The Rack::Handler::Agoo module is a handler for common rack config.rb files.
|
8
|
+
module Agoo
|
9
|
+
|
10
|
+
# Run the server. Options are the same as for Agoo::Server plus a :prot
|
11
|
+
# and :root option.
|
12
|
+
def self.run(handler, options={})
|
13
|
+
port = 9292
|
14
|
+
root = '.'
|
15
|
+
default_handler = nil
|
16
|
+
not_found_handler = nil
|
17
|
+
path_map = {}
|
18
|
+
|
19
|
+
default_handler = handler unless handler.nil?
|
20
|
+
options.each { |k,v|
|
21
|
+
if :port == k
|
22
|
+
port = v.to_i
|
23
|
+
options.delete(k)
|
24
|
+
elsif :root == k
|
25
|
+
root = v
|
26
|
+
options.delete(k)
|
27
|
+
elsif k.is_a?(String) && k.start_with?('/')
|
28
|
+
path_map[k] = v
|
29
|
+
options.delete(k)
|
30
|
+
elsif k.nil?
|
31
|
+
not_found_handler = v
|
32
|
+
options.delete(k)
|
33
|
+
end
|
34
|
+
}
|
35
|
+
options[:thread_count] = 0
|
36
|
+
server = ::Agoo::Server.new(port, root, options)
|
37
|
+
path_map.each { |path,handler|
|
38
|
+
server.handle(nil, path, handler)
|
39
|
+
}
|
40
|
+
unless default_handler.nil?
|
41
|
+
server.handle(nil, '/', default_handler)
|
42
|
+
server.handle(nil, '/**', default_handler)
|
43
|
+
end
|
44
|
+
server.handle_not_found(not_found_handler) unless not_found_handler.nil?
|
45
|
+
server.start
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
data/test/static_test.rb
CHANGED
metadata
CHANGED
@@ -1,19 +1,22 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: agoo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Ohler
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-03-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oj
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.4'
|
17
20
|
- - ">="
|
18
21
|
- !ruby/object:Gem::Version
|
19
22
|
version: 3.4.0
|
@@ -21,6 +24,9 @@ dependencies:
|
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '3.4'
|
24
30
|
- - ">="
|
25
31
|
- !ruby/object:Gem::Version
|
26
32
|
version: 3.4.0
|
@@ -72,6 +78,7 @@ files:
|
|
72
78
|
- ext/agoo/types.h
|
73
79
|
- lib/agoo.rb
|
74
80
|
- lib/agoo/version.rb
|
81
|
+
- lib/rack/handler/agoo.rb
|
75
82
|
- test/base_handler_test.rb
|
76
83
|
- test/log_test.rb
|
77
84
|
- test/rack_handler_test.rb
|