itsi-server 0.2.5 → 0.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Cargo.lock +1 -1
- data/ext/itsi_scheduler/Cargo.toml +1 -1
- data/ext/itsi_server/Cargo.toml +1 -1
- data/ext/itsi_server/src/services/static_file_server.rs +2 -2
- data/lib/itsi/http_request.rb +62 -45
- data/lib/itsi/server/config/middleware/grpc.md +1 -3
- data/lib/itsi/server/config/middleware/location.md +2 -2
- data/lib/itsi/server/config/middleware/log_requests.md +3 -1
- data/lib/itsi/server/config/middleware/proxy.md +7 -7
- data/lib/itsi/server/config/options/reuse_address.md +2 -0
- data/lib/itsi/server/config/options/reuse_address.rb +1 -1
- data/lib/itsi/server/config/options/reuse_port.md +2 -0
- data/lib/itsi/server/config/options/reuse_port.rb +1 -1
- data/lib/itsi/server/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5e35db14d9bab3c6242ac77ed848ced5bc848d9d46b4113029859c2e1d984773
|
4
|
+
data.tar.gz: 0a3c7930f80c67ea454ee29fff76906c70465f8f6e36ec903196f89d799dc4de
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e76c2016dc1d48492193bafa6e6d8af88a04affb4826745932a3060b8cf11351b84d06e12c87599cfc854a954dd17a628f8838affb4e9290937a829b5f22a31
|
7
|
+
data.tar.gz: b4f0b820e974710250ce2c776ebf7b8911668be9f9b6ade947023ebd3fb7f9770e6a07df348aaf38d385624771befaf531522d4bf44cb61c504356f8db960945
|
data/Cargo.lock
CHANGED
data/ext/itsi_server/Cargo.toml
CHANGED
@@ -662,7 +662,7 @@ impl StaticFileServer {
|
|
662
662
|
let range_length = end - start + 1;
|
663
663
|
let limited_reader = tokio::io::AsyncReadExt::take(file, range_length);
|
664
664
|
let path_clone = path.clone();
|
665
|
-
let stream = ReaderStream::
|
665
|
+
let stream = ReaderStream::with_capacity(limited_reader, 64 * 1024)
|
666
666
|
.map_ok(Frame::data)
|
667
667
|
.map_err(move |e| {
|
668
668
|
warn!("Error streaming file {}: {}", path_clone.display(), e);
|
@@ -681,7 +681,7 @@ impl StaticFileServer {
|
|
681
681
|
match File::open(&path).await {
|
682
682
|
Ok(file) => {
|
683
683
|
let path_clone = path.clone();
|
684
|
-
let stream = ReaderStream::
|
684
|
+
let stream = ReaderStream::with_capacity(file, 64 * 1024)
|
685
685
|
.map_ok(Frame::data)
|
686
686
|
.map_err(move |e| {
|
687
687
|
warn!("Error streaming file {}: {}", path_clone.display(), e);
|
data/lib/itsi/http_request.rb
CHANGED
@@ -25,56 +25,73 @@ module Itsi
|
|
25
25
|
hm.default_proc = proc { |_, key| "HTTP_#{key.upcase.gsub(/-/, "_")}" }
|
26
26
|
end
|
27
27
|
|
28
|
+
RACK_ENV_TEMPLATE = {
|
29
|
+
"SERVER_SOFTWARE" => "Itsi",
|
30
|
+
"rack.errors" => $stderr,
|
31
|
+
"rack.multithread" => true,
|
32
|
+
"rack.multiprocess" => true,
|
33
|
+
"rack.run_once" => false,
|
34
|
+
"rack.hijack?" => true,
|
35
|
+
"rack.multipart.buffer_size" => 16_384,
|
36
|
+
"SCRIPT_NAME" => "",
|
37
|
+
"REQUEST_METHOD" => "",
|
38
|
+
"PATH_INFO" => "",
|
39
|
+
"REQUEST_PATH" => "",
|
40
|
+
"QUERY_STRING" => "",
|
41
|
+
"REMOTE_ADDR" => "",
|
42
|
+
"SERVER_PORT" => "",
|
43
|
+
"SERVER_NAME" => "",
|
44
|
+
"SERVER_PROTOCOL" => "",
|
45
|
+
"HTTP_HOST" => "",
|
46
|
+
"HTTP_VERSION" => "",
|
47
|
+
"itsi.request" => "",
|
48
|
+
"itsi.response" => "",
|
49
|
+
"rack.version" => [nil],
|
50
|
+
"rack.url_scheme" => "",
|
51
|
+
"rack.input" => "",
|
52
|
+
"rack.hijack" => "",
|
53
|
+
"CONTENT_TYPE" => nil,
|
54
|
+
"CONTENT_LENGTH" => nil
|
55
|
+
}.freeze
|
56
|
+
|
28
57
|
def to_rack_env
|
29
58
|
path = self.path
|
30
59
|
host = self.host
|
31
60
|
version = self.version
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
when "accept-encoding" then "HTTP_ACCEPT_ENCODING"
|
65
|
-
when "accept-language" then "HTTP_ACCEPT_LANGUAGE"
|
66
|
-
when "user-agent" then "HTTP_USER_AGENT"
|
67
|
-
when "referer" then "HTTP_REFERER"
|
68
|
-
when "origin" then "HTTP_ORIGIN"
|
69
|
-
when "cookie" then "HTTP_COOKIE"
|
70
|
-
when "authorization" then "HTTP_AUTHORIZATION"
|
71
|
-
when "x-forwarded-for" then "HTTP_X_FORWARDED_FOR"
|
72
|
-
when "x-forwarded-proto" then "HTTP_X_FORWARDED_PROTO"
|
73
|
-
else RACK_HEADER_MAP[k]
|
74
|
-
end
|
75
|
-
] = v
|
76
|
-
end
|
61
|
+
env = RACK_ENV_TEMPLATE.dup
|
62
|
+
env["SCRIPT_NAME"] = script_name
|
63
|
+
env["REQUEST_METHOD"] = request_method
|
64
|
+
env["REQUEST_PATH"] = env["PATH_INFO"] = path
|
65
|
+
env["QUERY_STRING"] = query_string
|
66
|
+
env["REMOTE_ADDR"] = remote_addr
|
67
|
+
env["SERVER_PORT"] = port.to_s
|
68
|
+
env["HTTP_HOST"] = env["SERVER_NAME"] = host
|
69
|
+
env["HTTP_VERSION"] = env["SERVER_PROTOCOL"] = version
|
70
|
+
env["itsi.request"] = self
|
71
|
+
env["itsi.response"] = response
|
72
|
+
env["rack.version"][0] = version
|
73
|
+
env["rack.url_scheme"] = scheme
|
74
|
+
env["rack.input"] = build_input_io
|
75
|
+
env["rack.hijack"] = method(:hijack)
|
76
|
+
headers.each do |(k, v)|
|
77
|
+
env[case k
|
78
|
+
when "content-type" then "CONTENT_TYPE"
|
79
|
+
when "content-length" then "CONTENT_LENGTH"
|
80
|
+
when "accept" then "HTTP_ACCEPT"
|
81
|
+
when "accept-encoding" then "HTTP_ACCEPT_ENCODING"
|
82
|
+
when "accept-language" then "HTTP_ACCEPT_LANGUAGE"
|
83
|
+
when "user-agent" then "HTTP_USER_AGENT"
|
84
|
+
when "referer" then "HTTP_REFERER"
|
85
|
+
when "origin" then "HTTP_ORIGIN"
|
86
|
+
when "cookie" then "HTTP_COOKIE"
|
87
|
+
when "authorization" then "HTTP_AUTHORIZATION"
|
88
|
+
when "x-forwarded-for" then "HTTP_X_FORWARDED_FOR"
|
89
|
+
when "x-forwarded-proto" then "HTTP_X_FORWARDED_PROTO"
|
90
|
+
else RACK_HEADER_MAP[k]
|
91
|
+
end
|
92
|
+
] = v
|
77
93
|
end
|
94
|
+
env
|
78
95
|
end
|
79
96
|
|
80
97
|
def respond(
|
@@ -13,7 +13,6 @@ Under the covers it:
|
|
13
13
|
3. Automatically enables `gRPC` reflection (so client like `evans`, `grpcurl` or `Postman` can discover your service endpoints without needing access to raw `.proto` files).
|
14
14
|
4. Supports optional per‑call compression (`none`, `deflate`, `gzip`) and a non‑blocking execution mode.
|
15
15
|
|
16
|
-
---
|
17
16
|
|
18
17
|
## Usage
|
19
18
|
|
@@ -97,8 +96,7 @@ require_relative 'echo_service_impl'
|
|
97
96
|
|
98
97
|
bind "https://localhost:3000"
|
99
98
|
grpc EchoServiceImpl.new,
|
100
|
-
nonblocking: false
|
101
|
-
compression: 'gzip' do
|
99
|
+
nonblocking: false do
|
102
100
|
# Nested middleware still works:
|
103
101
|
response_headers additions: { 'X-Service' => ['Echo'] }
|
104
102
|
end
|
@@ -48,7 +48,7 @@ end
|
|
48
48
|
```ruby {filename="Itsi.rb"}
|
49
49
|
# Match on non-route options.
|
50
50
|
# Redirect http requests to https requests
|
51
|
-
location
|
51
|
+
location schemes: ["http"]
|
52
52
|
redirect type: :permanent, to: "https://{host}{path_and_query}"
|
53
53
|
end
|
54
54
|
```
|
@@ -101,7 +101,7 @@ Pass these to the location block using keyword arguments, e.g.
|
|
101
101
|
|
102
102
|
```ruby
|
103
103
|
# Redirect all http JSON requests to use https exclusively.
|
104
|
-
location
|
104
|
+
location schemes: ["http"], content_types: ["application/json"]
|
105
105
|
redirect type: :permanent, to: "https://{host}{path_and_query}"
|
106
106
|
end
|
107
107
|
```
|
@@ -21,7 +21,7 @@ log_requests \
|
|
21
21
|
```
|
22
22
|
|
23
23
|
|
24
|
-
The log statement can populated with several different placeholders.
|
24
|
+
The log statement can populated with several different placeholders, using [String Rewrite](/middleware/string_rewrite) functionality.
|
25
25
|
Available values are:
|
26
26
|
|
27
27
|
### `before` Format String
|
@@ -46,6 +46,8 @@ Available values are:
|
|
46
46
|
* `response_time` - The response time in milliseconds
|
47
47
|
* `<Header-Name>`: Any existing response header. For example `{Content-Type}` or `{Set-Cookie}` will be replaced with its current value.
|
48
48
|
|
49
|
+
See [String Rewrite](/middleware/string_rewrite) for more advanced string manipulation options.
|
50
|
+
|
49
51
|
|
50
52
|
### Path Attributes
|
51
53
|
In addition to this, any capture groups referenced by container location blocks
|
@@ -9,13 +9,13 @@ The Reverse Proxy middleware enables reverse proxying by forwarding incoming HTT
|
|
9
9
|
|
10
10
|
```ruby
|
11
11
|
proxy \
|
12
|
-
to: "http://backend.example.com/api{path}{query}",
|
13
|
-
backends: ["127.0.0.1:3001", "127.0.0.1:3002"],
|
14
|
-
backend_priority: "round_robin",
|
15
|
-
headers: { "X-Forwarded-For" => { rewrite: "{addr}" } },
|
16
|
-
verify_ssl: false,
|
17
|
-
timeout: 30,
|
18
|
-
tls_sni: true,
|
12
|
+
to: "http://backend.example.com/api{path}{query}",
|
13
|
+
backends: ["127.0.0.1:3001", "127.0.0.1:3002"],
|
14
|
+
backend_priority: "round_robin",
|
15
|
+
headers: { "X-Forwarded-For" => { rewrite: "{addr}" } },
|
16
|
+
verify_ssl: false,
|
17
|
+
timeout: 30,
|
18
|
+
tls_sni: true,
|
19
19
|
error_response: "bad_gateway"
|
20
20
|
```
|
21
21
|
## Options
|
@@ -6,6 +6,8 @@ url: /options/reuse_address
|
|
6
6
|
Configures whether the server should bind to the underlying socket using the `SO_REUSEADDR` option.
|
7
7
|
This option determines whether the server allows the reuse of local addresses during binding. This can be useful in scenarios where a socket needs to be quickly rebound without waiting for the operating system to release the address.
|
8
8
|
|
9
|
+
The default value is `false`.
|
10
|
+
|
9
11
|
## Configuration
|
10
12
|
```ruby {filename=Itsi.rb}
|
11
13
|
reuse_address true
|
@@ -6,6 +6,8 @@ url: /options/reuse_port
|
|
6
6
|
Configures whether the server should bind to the underlying socket using the `SO_REUSEPORT` option.
|
7
7
|
This option determines whether multiple sockets can listen on the same IP and port combination, which can improve load balancing and fault tolerance in multi-threaded or multi-process server applications.
|
8
8
|
|
9
|
+
The default value is `false`.
|
10
|
+
|
9
11
|
## Configuration
|
10
12
|
```ruby {filename=Itsi.rb}
|
11
13
|
reuse_port true
|
data/lib/itsi/server/version.rb
CHANGED