-
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.
feat(SCREO-xxxx): Fix issue swifter (#66)
* "import Swifter" no more mandatory in hosting application * "import Swifter" no more mandatory in hosting application
- Loading branch information
1 parent
7320fdc
commit da7c81a
Showing
8 changed files
with
47 additions
and
43 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 |
---|---|---|
@@ -1,5 +1,4 @@ | ||
import Foundation | ||
import Swifter | ||
|
||
struct ImageReponse { | ||
let path: String | ||
|
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,5 +1,4 @@ | ||
import Foundation | ||
import Swifter | ||
|
||
public protocol HttpRequest { | ||
var path: String { get } | ||
|
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,31 @@ | ||
import Foundation | ||
import Swifter | ||
|
||
public class HttpResponse { | ||
let body: Data | ||
let statusCode: Int | ||
let headers: [String : String] | ||
|
||
public init(body: Data = Data(), statusCode: Int = 200, headers: [String: String] = [:]) { | ||
self.body = body | ||
self.statusCode = statusCode | ||
self.headers = headers | ||
} | ||
} | ||
|
||
extension HttpResponse { | ||
public static func notFound() -> HttpResponse { | ||
return HttpResponse(statusCode: 404) | ||
} | ||
|
||
public static func badRequest() -> HttpResponse { | ||
return HttpResponse(statusCode: 400) | ||
} | ||
|
||
func toSwifter() -> Swifter.HttpResponse { | ||
return Swifter.HttpResponse.raw(statusCode, "", headers) { (writer) in | ||
try writer.write(self.body) | ||
} | ||
} | ||
} | ||
|
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