@@ -6,9 +6,10 @@ import cask.model._
66import cask .router .{Decorator , EndpointMetadata , EntryPoint , Result }
77import cask .util .Logger
88import io .undertow .Undertow
9- import io .undertow .server .handlers .BlockingHandler
109import io .undertow .server .{HttpHandler , HttpServerExchange }
10+ import io .undertow .server .handlers .BlockingHandler
1111import io .undertow .util .HttpString
12+ import org .xnio .Options
1213
1314import java .util .concurrent .ExecutorService
1415
@@ -83,12 +84,28 @@ abstract class Main{
8384 Main .defaultHandleError(routes, metadata, e, debugMode, req)
8485 }
8586
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+
8697 def main (args : Array [String ]): Unit = {
8798 if (! verbose) Main .silenceJboss()
88- val server = Undertow .builder
99+ val builder = Undertow .builder
89100 .addHttpListener(port, host)
90101 .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()
92109 server.start()
93110 // register an on exit hook to stop the server
94111 Runtime .getRuntime.addShutdownHook(new Thread (() => {
0 commit comments