Skip to content

Commit

Permalink
upgrade name conflict
Browse files Browse the repository at this point in the history
## Problem
Message and Request both uses “upgrade”

## Reason

S4 Defines Request is following protocol but upgrade for two different
reason.
```
public struct Request: Message {
```

## Fix
request.upgrade changes to
request.onUpgrade since this is callback function
  • Loading branch information
Tomohisa Takaoka committed Apr 22, 2016
1 parent 5473298 commit 06c3706
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions Sources/Response.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,46 +23,46 @@
// SOFTWARE.

extension Response {
public typealias Upgrade = (Request, Stream) throws -> Void
public typealias OnUpgrade = (Request, Stream) throws -> Void

public var upgrade: Upgrade? {
public var onUpgrade: OnUpgrade? {
get {
return storage["response-connection-upgrade"] as? Upgrade
return storage["response-connection-upgrade"] as? OnUpgrade
}

set(upgrade) {
storage["response-connection-upgrade"] = upgrade
set(onUpgrade) {
storage["response-connection-upgrade"] = onUpgrade
}
}
}

extension Response {
public init(status: Status = .ok, headers: Headers = [:], body: Stream, upgrade: Upgrade?) {
public init(status: Status = .ok, headers: Headers = [:], body: Stream, onUpgrade: OnUpgrade?) {
self.init(
status: status,
headers: headers,
body: body
)

self.upgrade = upgrade
self.onUpgrade = onUpgrade
}

public init(status: Status = .ok, headers: Headers = [:], body: Data = Data(), upgrade: Upgrade?) {
public init(status: Status = .ok, headers: Headers = [:], body: Data = Data(), onUpgrade: OnUpgrade?) {
self.init(
status: status,
headers: headers,
body: body
)

self.upgrade = upgrade
self.onUpgrade = onUpgrade
}

public init(status: Status = .ok, headers: Headers = [:], body: DataConvertible, upgrade: Upgrade? = nil) {
public init(status: Status = .ok, headers: Headers = [:], body: DataConvertible, onUpgrade: OnUpgrade? = nil) {
self.init(
status: status,
headers: headers,
body: body.data,
upgrade: upgrade
onUpgrade: onUpgrade
)
}
}
Expand Down

0 comments on commit 06c3706

Please sign in to comment.