nut 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +23 -0
- data/lib/nut/handler.rb +3 -0
- data/lib/nut/service.rb +3 -2
- data/lib/nut/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a735347aacab5f841d7e7002bb1974e4e1d392b
|
4
|
+
data.tar.gz: 85d2efe284e74dd48a85f246320ac5b54804000f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 110e11a0fa8ce38b7a99b4340ad134acab2329edb46c6c44f1b525cf42141f194af1d7e2813beee607956102d13e21f4ae4578045c96b3babe574ffac58d2692
|
7
|
+
data.tar.gz: e8e4033f1ea84ae38bd174c8a7f162668864a9f9818e3c20b1b12ed50dbb75db73c36e187756ca983da0a5482e671e22b382d1925f9f620c119227b8bbb30e85
|
data/README.md
CHANGED
@@ -26,6 +26,29 @@ gem install -V nut
|
|
26
26
|
Nut is a miniature pure-Ruby implementation of a reactive HTTP Server.
|
27
27
|
Relying on [RxIO](https://rubygems.org/gems/rxio), Nut is simple to use, fast and lightweight.
|
28
28
|
|
29
|
+
### Creating a Service
|
30
|
+
|
31
|
+
Creating a service is as simple as:
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
# Create Nut Server
|
35
|
+
n = Nut::Service.new YourRequestHandler
|
36
|
+
```
|
37
|
+
|
38
|
+
The service can be made to listen on a specific address / port:
|
39
|
+
|
40
|
+
```ruby
|
41
|
+
# Create Nut Server
|
42
|
+
n = Nut::Service.new 'localhost', 4444, YourRequestHandler
|
43
|
+
```
|
44
|
+
|
45
|
+
Finally, the service can also be made to serve HTTPS instead of HTTP:
|
46
|
+
|
47
|
+
```ruby
|
48
|
+
# Create Nut Server
|
49
|
+
n = Nut::Service.new 'localhost', 4444, { cert: 'cert.pem', pkey: 'private.key' }, YourRequestHandler
|
50
|
+
```
|
51
|
+
|
29
52
|
### Request Handler
|
30
53
|
Nut uses a request_handler module to service client requests. This module is to be implemented by the user.
|
31
54
|
The request_handler module requires only one method: _handle_, which takes two Hashes as arguments: _request_ and _response_.
|
data/lib/nut/handler.rb
CHANGED
data/lib/nut/service.rb
CHANGED
@@ -26,11 +26,12 @@ module Nut
|
|
26
26
|
# Builds a *Service* set to listen for incoming connections @ _addr_ on _port_.
|
27
27
|
# @param [String] addr
|
28
28
|
# @param [Fixnum] port
|
29
|
+
# @param [Hash] ssl_params
|
29
30
|
# @param [Module] request_handler
|
30
|
-
def initialize addr = DEFAULT_ADDR, port = DEFAULT_PORT, request_handler
|
31
|
+
def initialize addr = DEFAULT_ADDR, port = DEFAULT_PORT, ssl_params = nil, request_handler
|
31
32
|
|
32
33
|
# Super
|
33
|
-
super addr, port, Handler
|
34
|
+
super addr, port, Handler, ssl_params
|
34
35
|
|
35
36
|
# Set Request Handler
|
36
37
|
@request_handler = request_handler
|
data/lib/nut/version.rb
CHANGED