Skip to content

Commit

Permalink
Improve initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
guoye-zhang committed Nov 4, 2024
1 parent a85ca15 commit 37e6ad1
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions Sources/NIOResumableUploadDemo/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -101,17 +101,16 @@ if #available(macOS 13.0, iOS 16.0, tvOS 16.0, watchOS 9.0, *) {

let group = MultiThreadedEventLoopGroup(numberOfThreads: System.coreCount)
let server = try ServerBootstrap(group: group).childChannelInitializer { channel in
let handler = HTTP1ToHTTPServerCodec(secure: false)
return channel.pipeline.addHandlers([
handler,
HTTPResumableUploadHandler(
context: uploadContext,
handlers: [
UploadServerHandler(directory: URL(fileURLWithPath: CommandLine.arguments[1], isDirectory: true))
]
),
]).flatMap { _ in
channel.pipeline.configureHTTPServerPipeline(position: .before(handler))
channel.pipeline.configureHTTPServerPipeline().flatMap {
channel.pipeline.addHandlers([
HTTP1ToHTTPServerCodec(secure: false),
HTTPResumableUploadHandler(
context: uploadContext,
handlers: [
UploadServerHandler(directory: URL(fileURLWithPath: CommandLine.arguments[1], isDirectory: true))
]
),
])
}
}
.bind(host: "0.0.0.0", port: 8080)
Expand Down

0 comments on commit 37e6ad1

Please sign in to comment.