ChannelPipeline: addHandler and removeHandler instead of add/remove (#817)

Motivation:

- `ChannelPipeline.add(name:handler:...)` had a strange order of arguments
- `remove(handler:)` and `remove(ctx:)` both remove `ChannelHandler`s
  but they read like they remove different things

So let's just fix the argument order and name them `addHandler` and
`removeHandler` making clear what they do.

Modifications:

- rename all `ChannelPipeline.add(name:handler:...)`s to `ChannelPipeline.addHandler(_:name:...)`
- rename all `ChannelPipeline.remove(...)`s to `ChannelPipeline.removeHandler(...)`

Result:

more readable and consistent code
This commit is contained in:
Johannes Weiss authored and GitHub committed 2019-02-21 11:46:54 +00:00
1 parent 5d27e59bd9
commit 46ffd630de
50 files changed
+539 -425

No files matched your search

@@ -29,7 +29,7 @@ class HTTPRequestEncoderTests: XCTestCase {
XCTAssertEqual(.some(false), try? channel.finish())
}
try channel.pipeline.add(handler: HTTPRequestEncoder()).wait()
try channel.pipeline.addHandler(HTTPRequestEncoder()).wait()
var request = HTTPRequestHead(version: HTTPVersion(major: 1, minor:1), method: method, uri: "/uri")
request.headers = headers
try channel.writeOutbound(HTTPClientRequestPart.head(request))
@@ -78,7 +78,7 @@ class HTTPRequestEncoderTests: XCTestCase {
XCTAssertEqual(.some(false), try? channel.finish())
}
XCTAssertNoThrow(try channel.pipeline.add(handler: HTTPRequestEncoder()).wait())
XCTAssertNoThrow(try channel.pipeline.addHandler(HTTPRequestEncoder()).wait())
// This request contains neither Transfer-Encoding: chunked or Content-Length.
let request = HTTPRequestHead(version: HTTPVersion(major: 1, minor:0), method: .GET, uri: "/uri")
@@ -94,7 +94,7 @@ class HTTPRequestEncoderTests: XCTestCase {
XCTAssertEqual(.some(false), try? channel.finish())
}
try channel.pipeline.add(handler: HTTPRequestEncoder()).wait()
try channel.pipeline.addHandler(HTTPRequestEncoder()).wait()
var request = HTTPRequestHead(version: HTTPVersion(major: 1, minor:1), method: .POST, uri: "/uri")
request.headers.add(name: "content-length", value: "4")
@@ -117,7 +117,7 @@ class HTTPRequestEncoderTests: XCTestCase {
}
let uri = "server.example.com:80"
try channel.pipeline.add(handler: HTTPRequestEncoder()).wait()
try channel.pipeline.addHandler(HTTPRequestEncoder()).wait()
var request = HTTPRequestHead(version: HTTPVersion(major: 1, minor:1), method: .CONNECT, uri: uri)
request.headers.add(name: "Host", value: uri)