Skip to content

Commit

Permalink
Escaping closures
Browse files Browse the repository at this point in the history
  • Loading branch information
pvzig committed Sep 13, 2016
1 parent 192d04f commit 0b4fada
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ DerivedData
*.hmap
*.ipa
*.xcuserstate
*.DS_Store

# CocoaPods
#
Expand Down
12 changes: 6 additions & 6 deletions Sources/Swifter/HttpServer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,27 +32,27 @@ public class HttpServer: HttpServerIO {
public var DELETE, UPDATE, HEAD, POST, GET, PUT : MethodRoute
public var delete, update, head, post, get, put : MethodRoute

public func get(_ path: String, _ handler: ((HttpRequest) -> HttpResponse)) {
public func get(_ path: String, _ handler: @escaping ((HttpRequest) -> HttpResponse)) {
router.register("GET", path: path, handler: handler)
}

public func post(_ path: String, _ handler: ((HttpRequest) -> HttpResponse)) {
public func post(_ path: String, _ handler: @escaping ((HttpRequest) -> HttpResponse)) {
router.register("POST", path: path, handler: handler)
}

public func put(_ path: String, _ handler: ((HttpRequest) -> HttpResponse)) {
public func put(_ path: String, _ handler: @escaping ((HttpRequest) -> HttpResponse)) {
router.register("PUT", path: path, handler: handler)
}

public func head(_ path: String, _ handler: ((HttpRequest) -> HttpResponse)) {
public func head(_ path: String, _ handler: @escaping ((HttpRequest) -> HttpResponse)) {
router.register("HEAD", path: path, handler: handler)
}

public func delete(_ path: String, _ handler: ((HttpRequest) -> HttpResponse)) {
public func delete(_ path: String, _ handler: @escaping ((HttpRequest) -> HttpResponse)) {
router.register("DELETE", path: path, handler: handler)
}

public func update(_ path: String, _ handler: ((HttpRequest) -> HttpResponse)) {
public func update(_ path: String, _ handler: @escaping ((HttpRequest) -> HttpResponse)) {
router.register("UPDATE", path: path, handler: handler)
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/Swifter/Scopes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import Foundation
#endif

public func scopes(_ scope: Closure) -> ((HttpRequest) -> HttpResponse) {
public func scopes(_ scope: @escaping Closure) -> ((HttpRequest) -> HttpResponse) {
return { r in
ScopesBuffer[Process.tid] = ""
scope()
Expand Down

0 comments on commit 0b4fada

Please sign in to comment.