@@ -6,9 +6,10 @@ import cask.model._
6
6
import cask .router .{Decorator , EndpointMetadata , EntryPoint , Result }
7
7
import cask .util .Logger
8
8
import io .undertow .Undertow
9
- import io .undertow .server .handlers .BlockingHandler
10
9
import io .undertow .server .{HttpHandler , HttpServerExchange }
10
+ import io .undertow .server .handlers .BlockingHandler
11
11
import io .undertow .util .HttpString
12
+ import org .xnio .Options
12
13
13
14
import java .util .concurrent .ExecutorService
14
15
@@ -83,12 +84,28 @@ abstract class Main{
83
84
Main .defaultHandleError(routes, metadata, e, debugMode, req)
84
85
}
85
86
87
+ /**
88
+ * Set server options for the undertow server. By default, no options are set.
89
+ * */
90
+ protected def serverOptions : List [(org.xnio.Option [_], Any )] = Nil
91
+
92
+ /**
93
+ * Set server options for the undertow server. By default, no options are set.
94
+ * */
95
+ protected def socketOptions : List [(org.xnio.Option [_], Any )] = Nil
96
+
86
97
def main (args : Array [String ]): Unit = {
87
98
if (! verbose) Main .silenceJboss()
88
- val server = Undertow .builder
99
+ val builder = Undertow .builder
89
100
.addHttpListener(port, host)
90
101
.setHandler(defaultHandler)
91
- .build
102
+ serverOptions.foreach {
103
+ case (option : org.xnio.Option [Any @ unchecked], value) => builder.setServerOption(option, value)
104
+ }
105
+ socketOptions.foreach {
106
+ case (option : org.xnio.Option [Any @ unchecked], value) => builder.setSocketOption(option, value)
107
+ }
108
+ val server = builder.build()
92
109
server.start()
93
110
// register an on exit hook to stop the server
94
111
Runtime .getRuntime.addShutdownHook(new Thread (() => {
0 commit comments