diff --git a/Source/Localhost/LocalhostRouter.swift b/Source/Localhost/LocalhostRouter.swift index 6419187..51a44c6 100644 --- a/Source/Localhost/LocalhostRouter.swift +++ b/Source/Localhost/LocalhostRouter.swift @@ -15,6 +15,9 @@ public protocol LocalhostRouter { func post(_ path: String, routeBlock: @escaping ((URLRequest) -> LocalhostServerResponse?)) func delete(_ path: String, routeBlock: @escaping ((URLRequest) -> LocalhostServerResponse?)) func put(_ path: String, routeBlock: @escaping ((URLRequest) -> LocalhostServerResponse?)) + func patch(_ path: String, routeBlock: @escaping ((URLRequest) -> LocalhostServerResponse?)) + func options(_ path: String, routeBlock: @escaping ((URLRequest) -> LocalhostServerResponse?)) + func head(_ path: String, routeBlock: @escaping ((URLRequest) -> LocalhostServerResponse?)) func startListening() func stopListening() diff --git a/Source/Localhost/LocalhostServer.swift b/Source/Localhost/LocalhostServer.swift index d59cf3c..f65a1db 100644 --- a/Source/Localhost/LocalhostServer.swift +++ b/Source/Localhost/LocalhostServer.swift @@ -47,6 +47,15 @@ extension LocalhostServer: LocalhostRouter { }) } + public func patch(_ path: String, routeBlock: @escaping ((URLRequest) -> LocalhostServerResponse?)) { + self.server.add(path, block: { [weak self] (req, res, next) in + self?.handleRoute(httpMethod: "PATCH", + routeBlock: routeBlock, + crRequest: req, + crResponse: res) + }, recursive: false, method: .patch) + } + public func head(_ path: String, routeBlock: @escaping ((URLRequest) -> LocalhostServerResponse?)) { self.server.head(path, block: { [weak self] (req, res, next) in self?.handleRoute(httpMethod: "HEAD",