|
13 | 13 | # Define HTTP/1 endpoint configuration: |
14 | 14 | http1 = environment do |
15 | 15 | include Falcon::Environment::Server |
16 | | - |
| 16 | + |
17 | 17 | scheme "http" |
18 | | - protocol { Async::HTTP::Protocol::HTTP1 } |
19 | | - |
| 18 | + protocol {Async::HTTP::Protocol::HTTP1} |
| 19 | + |
20 | 20 | endpoint do |
21 | 21 | Async::HTTP::Endpoint.for( |
22 | 22 | scheme, |
|
30 | 30 | # Define HTTP/2 endpoint configuration: |
31 | 31 | http2 = environment do |
32 | 32 | include Falcon::Environment::Server |
33 | | - |
| 33 | + |
34 | 34 | scheme "http" |
35 | | - protocol { Async::HTTP::Protocol::HTTP2 } |
36 | | - |
| 35 | + protocol {Async::HTTP::Protocol::HTTP2} |
| 36 | + |
37 | 37 | endpoint do |
38 | 38 | Async::HTTP::Endpoint.for( |
39 | 39 | scheme, |
|
47 | 47 | # Main service that runs the same application on both endpoints: |
48 | 48 | service "multi-protocol" do |
49 | 49 | include Falcon::Environment::Rack |
50 | | - |
51 | | - protocol_http1 { http1.with(middleware: self.middleware).evaluator } |
52 | | - protocol_http2 { http2.with(middleware: self.middleware).evaluator } |
53 | | - |
| 50 | + |
| 51 | + protocol_http1 {http1.with(middleware: self.middleware).evaluator} |
| 52 | + protocol_http2 {http2.with(middleware: self.middleware).evaluator} |
| 53 | + |
54 | 54 | # Use NamedEndpoints to combine both endpoints: |
55 | 55 | endpoint do |
56 | 56 | endpoints = { |
57 | 57 | protocol_http1: protocol_http1.endpoint, |
58 | 58 | protocol_http2: protocol_http2.endpoint |
59 | 59 | } |
60 | | - |
| 60 | + |
61 | 61 | IO::Endpoint::NamedEndpoints.new(endpoints) |
62 | 62 | end |
63 | | - |
| 63 | + |
64 | 64 | # Create servers for each named endpoint: |
65 | 65 | make_server do |bound_endpoint| |
66 | 66 | servers = {} |
67 | | - |
| 67 | + |
68 | 68 | bound_endpoint.each do |name, endpoint| |
69 | 69 | servers[name.to_s] = self[name].make_server(endpoint) |
70 | 70 | end |
71 | | - |
| 71 | + |
72 | 72 | Falcon::CompositeServer.new(servers) |
73 | 73 | end |
74 | 74 | end |
0 commit comments