-
-
Save sturdysturge/3f8eb8a56fccaab8a72e8dc87bbf9dcb to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| import Plot | |
| import Vapor | |
| extension Response.Body { | |
| init(html: HTML) { | |
| self.init(string: html.render()) | |
| } | |
| } | |
| extension Response { | |
| convenience init(_ html: HTML) { | |
| self.init(status: .ok, headers: ["Content-Type": "text/html"], body: .init(html: html)) | |
| } | |
| } | |
| extension HTML { | |
| func response() -> Response { | |
| Response(self) | |
| } | |
| } | |
| extension HTML: ResponseEncodable { | |
| public func encodeResponse(for request: Request) -> EventLoopFuture<Response> { | |
| request.eventLoop.makeSucceededFuture(Response(self)) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
AsyncResponseEncodable :)