Skip to content

Commit fbffd02

Browse files
authored
Merge pull request #443 from cobbal/stable
Make HttpServer an open class for customization
2 parents 74d111d + c80a1c0 commit fbffd02

File tree

4 files changed

+6
-5
lines changed

4 files changed

+6
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ All notable changes to this project will be documented in this file. Changes not
2525

2626
## Changed
2727

28+
- Turn `HttpServer` and `HttpServerIO` into open classes to allow for more customization. ([#443](https://github.com/httpswift/swifter/pull/443)) by [@cobbal](https://github.com/cobbal)
2829
- Set the version of the HTTP Server based in the project version in the **Info.plist** for macOS, iOS and tvOS platforms. ([#416](https://github.com/httpswift/swifter/pull/416)) by [@Vkt0r](https://github.com/Vkt0r)
2930
- Update `HttpParser` so it percent-encodes the URL components before initializing `URLComponents`. ([#423](https://github.com/httpswift/swifter/pull/423)) by [@nejcvivod](https://github.com/nejcvivod)
3031
- Update `SwifterTestsHttpParser` with a test for parsing bracketed query strings. ([#423](https://github.com/httpswift/swifter/pull/423)) by [@nejcvivod](https://github.com/nejcvivod)

Dangerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ swiftlint.config_file = '.swiftlint.yml'
2626
swiftlint.lint_files
2727

2828
# Warn when new tests are added but the XCTestManifests wasn't updated to run on Linux
29-
tests_added_or_modified = git.modified_files.grep(/XCode\/Tests/).empty? || git.added_files.grep(/XCode\/Tests/).empty?
29+
tests_added_or_modified = !git.modified_files.grep(/XCode\/Tests/).empty? || !git.added_files.grep(/XCode\/Tests/).empty?
3030
xc_manifest_updated = !git.modified_files.grep(/XCode\/Tests\/XCTestManifests.swift/).empty?
3131
if tests_added_or_modified && !xc_manifest_updated
3232
warn("It seems like you've added new tests to the library. If that's the case, please update the [XCTestManifests.swift](https://github.com/httpswift/swifter/blob/stable/XCode/Tests/XCTestManifests.swift) file running in your terminal the command `swift test --generate-linuxmain`.")

XCode/Sources/HttpServer.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import Foundation
99

10-
public class HttpServer: HttpServerIO {
10+
open class HttpServer: HttpServerIO {
1111

1212
public static let VERSION: String = {
1313

@@ -56,7 +56,7 @@ public class HttpServer: HttpServerIO {
5656

5757
public var middleware = [(HttpRequest) -> HttpResponse?]()
5858

59-
override public func dispatch(_ request: HttpRequest) -> ([String: String], (HttpRequest) -> HttpResponse) {
59+
override open func dispatch(_ request: HttpRequest) -> ([String: String], (HttpRequest) -> HttpResponse) {
6060
for layer in middleware {
6161
if let response = layer(request) {
6262
return ([:], { _ in response })

XCode/Sources/HttpServerIO.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public protocol HttpServerIODelegate: class {
1212
func socketConnectionReceived(_ socket: Socket)
1313
}
1414

15-
public class HttpServerIO {
15+
open class HttpServerIO {
1616

1717
public weak var delegate: HttpServerIODelegate?
1818

@@ -111,7 +111,7 @@ public class HttpServerIO {
111111
self.state = .stopped
112112
}
113113

114-
public func dispatch(_ request: HttpRequest) -> ([String: String], (HttpRequest) -> HttpResponse) {
114+
open func dispatch(_ request: HttpRequest) -> ([String: String], (HttpRequest) -> HttpResponse) {
115115
return ([:], { _ in HttpResponse.notFound })
116116
}
117117

0 commit comments

Comments
 (0)