forked from Building42/Telegraph
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move deprecations to a separate file
- Loading branch information
Showing
10 changed files
with
135 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
// | ||
// Deprecations.swift | ||
// Telegraph | ||
// | ||
// Created by Yvo van Beek on 11/9/18. | ||
// Copyright © 2018 Building42. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
// MARK: - DateFormatter | ||
|
||
public extension DateFormatter { | ||
@available(*, deprecated, message: "use DateFormatter.rfc1123 or Date's rfc1123 variable") | ||
public var rfc7231: DateFormatter { | ||
return .rfc1123 | ||
} | ||
} | ||
|
||
// MARK: - DispatchTimer | ||
|
||
public extension DispatchTimer { | ||
/// Creates and starts a timer that runs after a while, optionally repeating with a specific interval. | ||
@available(*, deprecated, message: "no longer supported, use start(at:) to run the timer at a later time") | ||
static func run(after: TimeInterval, interval: TimeInterval = 0, queue: DispatchQueue, execute block: @escaping () -> Void) -> DispatchTimer { | ||
let timer = DispatchTimer(interval: interval, queue: queue, execute: block) | ||
timer.start(at: Date() + after) | ||
return timer | ||
} | ||
|
||
/// (Re)starts the timer, next run will be after the specified interval. | ||
@available(*, deprecated, message: "no longer supported, use start(at:) to run the timer at a later time") | ||
public func start(after: TimeInterval) { | ||
start(at: Date() + after) | ||
} | ||
} | ||
|
||
// MARK: - HTTPHeader | ||
|
||
@available(*, deprecated, message: "use HTTPHeaderName") | ||
typealias HTTPHeader = HTTPHeaderName | ||
|
||
@available(*, deprecated, message: "use Dictionary") | ||
typealias CustomKeyIndexable = Dictionary | ||
|
||
// MARK: - HTTPMethod | ||
|
||
public extension HTTPMethod { | ||
@available(*, deprecated, message: "use HTTPMethod.GET") | ||
static var get = HTTPMethod.GET | ||
|
||
@available(*, deprecated, message: "use HTTPMethod.HEAD") | ||
static var head = HTTPMethod.HEAD | ||
|
||
@available(*, deprecated, message: "use HTTPMethod.DELETE") | ||
static var delete = HTTPMethod.DELETE | ||
|
||
@available(*, deprecated, message: "use HTTPMethod.OPTIONS") | ||
static var options = HTTPMethod.OPTIONS | ||
|
||
@available(*, deprecated, message: "use HTTPMethod.POST") | ||
static var post = HTTPMethod.POST | ||
|
||
@available(*, deprecated, message: "use HTTPMethod.PUT") | ||
static var put = HTTPMethod.PUT | ||
|
||
@available(*, deprecated, message: "use HTTPMethod(name:)") | ||
init(rawValue: String) { | ||
self.init(name: rawValue.uppercased()) | ||
} | ||
|
||
@available(*, deprecated, message: "use HTTPMethod(name:)") | ||
static func method(_ name: String) -> HTTPMethod { | ||
return HTTPMethod(name: name) | ||
} | ||
} | ||
|
||
// MARK: - HTTPReponse | ||
|
||
extension HTTPResponse { | ||
@available(*, deprecated, message: "use DateFormatter.rfc1123 or Date's rfc1123 variable") | ||
public static let dateFormatter = DateFormatter.rfc1123 | ||
|
||
@available(*, deprecated, message: "data: has been renamed to body:") | ||
public convenience init(_ status: HTTPStatus = .ok, data: Data) { | ||
self.init(status, body: data) | ||
} | ||
|
||
@available(*, deprecated, message: "use keepAlive instead, this setter only handles true properly") | ||
public var closeAfterWrite: Bool { | ||
get { return !keepAlive } | ||
set { if newValue { headers.connection = "close" } } | ||
} | ||
} | ||
|
||
// MARK: - HTTPVersion | ||
|
||
public extension HTTPVersion { | ||
@available(*, deprecated, message: "use HTTPVersion(major:, minor:)") | ||
public init(_ major: UInt, _ minor: UInt) { | ||
self.init(major: major, minor: minor) | ||
} | ||
} | ||
|
||
// MARK: - Server | ||
|
||
extension Server { | ||
@available(*, deprecated, message: "use start(port:)") | ||
open func start(onPort port: UInt16) throws { | ||
try start(port: Int(port)) | ||
} | ||
|
||
@available(*, deprecated, message: "use start(port:interface:)") | ||
open func start(onInterface interface: String?, port: UInt16 = 0) throws { | ||
try start(port: Int(port), interface: interface) | ||
} | ||
} | ||
|
||
// MARK: - URI | ||
|
||
extension URI { | ||
@available(*, deprecated, message: "fragment should not be used, it is only relevant for URLs") | ||
public var fragment: String? { | ||
get { return nil } | ||
set { } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters