Skip to content

Commit c905153

Browse files
committed
Move handling of :ssl-context into aleph.tcp/start-server itself
While `:ssl-context` is still supported by `aleph.netty/start-server` for backwards compatibility, it now warns about its use. The motivation is to encourage callers to keep the whole pipeline setup code in a single place to hopefully make it easier to understand at a glance.
1 parent 6337d93 commit c905153

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

Diff for: src/aleph/tcp.clj

+18-13
Original file line numberDiff line numberDiff line change
@@ -88,19 +88,24 @@
8888
epoll? false
8989
shutdown-timeout netty/default-shutdown-timeout}
9090
:as options}]
91-
(netty/start-server
92-
{:pipeline-builder (fn [^ChannelPipeline pipeline]
93-
(.addLast pipeline
94-
"handler"
95-
(server-channel-handler handler options))
96-
(pipeline-transform pipeline))
97-
:ssl-context ssl-context
98-
:bootstrap-transform bootstrap-transform
99-
:socket-address (if socket-address
100-
socket-address
101-
(InetSocketAddress. port))
102-
:transport (netty/determine-transport transport epoll?)
103-
:shutdown-timeout shutdown-timeout}))
91+
(let [ssl-context (some-> ssl-context netty/coerce-ssl-server-context)]
92+
(netty/start-server
93+
{:pipeline-builder (fn [^ChannelPipeline pipeline]
94+
(when ssl-context
95+
(.addFirst pipeline
96+
"ssl-handler"
97+
(let [ch (.channel pipeline)]
98+
(netty/ssl-handler ch ssl-context))))
99+
(.addLast pipeline
100+
"handler"
101+
(server-channel-handler handler options))
102+
(pipeline-transform pipeline))
103+
:bootstrap-transform bootstrap-transform
104+
:socket-address (if socket-address
105+
socket-address
106+
(InetSocketAddress. port))
107+
:transport (netty/determine-transport transport epoll?)
108+
:shutdown-timeout shutdown-timeout})))
104109

105110
(defn- client-channel-handler
106111
"Returns a vector of `[d handler]`, where `d` is a deferred containing the

0 commit comments

Comments
 (0)