@@ -430,8 +430,11 @@ import func http.createServer
430430public extension Express {
431431
432432 /**
433- * Create an HTTP server (using http.server) with the `Express` instance
434- * as the handler, and then start listening.
433+ * Create an HTTP server (using `http.createServer`) with the ``Express``
434+ * instance as the handler, and then start listening.
435+ *
436+ * Returns the `http.Server`, so that additional event handlers
437+ * can be registered (e.g. `onError`, `onListening`).
435438 *
436439 * - Parameters:
437440 * - port : The port the server should listen on.
@@ -445,16 +448,22 @@ public extension Express {
445448 @discardableResult
446449 func listen( _ port: Int ? = nil , _ host: String = " 0.0.0.0 " ,
447450 backlog: Int = 512 ,
448- onListening execute: ( ( http . Server ) -> Void ) ? = nil ) -> Self
451+ onListening execute: ( ( http . Server ) -> Void ) ? = nil )
452+ -> http . Server
449453 {
450454 let server = http. createServer ( handler: requestHandler)
451- _ = server. listen ( port, host, backlog: backlog, onListening: execute)
452- return self
455+ _ = server. listen ( port, host, backlog: backlog,
456+ onListening: execute)
457+ return server
453458 }
454459
455460 /**
456- * Create an HTTP server (using http.server) with the `Express` instance
457- * as the handler, and then start listening.
461+ * Create an HTTP server (using `http.createServer`) with the ``Express``
462+ * instance as the handler, and then start listening.
463+ *
464+ * Returns the `http.Server`, so that additional event handlers
465+ * can be registered (e.g. `onError`, `onListening`).
466+ *
458467 *
459468 * - Parameters:
460469 * - port : The port the server should listen on.
@@ -467,7 +476,7 @@ public extension Express {
467476 @inlinable
468477 @discardableResult
469478 func listen( _ port: Int ? , _ host: String = " 0.0.0.0 " , backlog: Int = 512 ,
470- onListening execute: @escaping ( ) -> Void ) -> Self
479+ onListening execute: @escaping ( ) -> Void ) -> http . Server
471480 {
472481 return listen ( port, host, backlog: backlog) { _ in execute ( ) }
473482 }
0 commit comments