0001    //
0002    // Based on comment from ElvishJerricco <https://www.reddit.com/r/swift/comments/42n46u/a_laravellumen_inspired_web_framework_for_swift/czc3nw8>
0003    //
0004    // Allows Request closures to simply return `String`s, `Dictionary`s, or `Array`s. 
0005    //
0006    // Additionally, Vapor projects may define their own `ResponseConvertible` objects
0007    //
0008    
0009    import Foundation
0010    
0011    public protocol ResponseConvertible
Application+Route.swift:23
        public typealias Handler = Request throws -> ResponseConvertible
Controller.swift:9
	func index(request: Request) throws -> ResponseConvertible
Controller.swift:12
    func store(request: Request) throws -> ResponseConvertible
Controller.swift:15
    func show(request: Request) throws -> ResponseConvertible
Controller.swift:18
    func update(request: Request) throws -> ResponseConvertible
Controller.swift:21
    func destroy(request: Request) throws -> ResponseConvertible
ResponseConvertible.swift:16
extension Response: ResponseConvertible {
ResponseConvertible.swift:22
extension String: ResponseConvertible {
ResponseConvertible.swift:28
extension Dictionary: ResponseConvertible {
ResponseConvertible.swift:38
extension Array: ResponseConvertible {
ResponseConvertible.swift:48
extension NSDictionary: ResponseConvertible {
ResponseConvertible.swift:58
extension NSArray: ResponseConvertible {
Vapor+JSON.swift:16
extension Json: ResponseConvertible {
View.swift:45
extension View: ResponseConvertible {
{ 0012 func response
Application+Route.swift:109
            return try handler(request).response()
() -> Response 0013 } 0014 0015 0016 extension Response: ResponseConvertible { 0017 public func response() -> Response { 0018 return self 0019 } 0020 } 0021 0022 extension String: ResponseConvertible { 0023 public func response() -> Response { 0024 return Response(status: .OK, html: self) 0025 } 0026 } 0027 0028 extension Dictionary: ResponseConvertible { 0029 public func response() -> Response { 0030 do { 0031 return try Response(status: .OK, json: self) 0032 } catch { 0033 return Response(error: "JSON serialization error: \(error)") 0034 } 0035 } 0036 } 0037 0038 extension Array: ResponseConvertible { 0039 public func response() -> Response { 0040 do { 0041 return try Response(status: .OK, json: self) 0042 } catch { 0043 return Response(error: "JSON serialization error: \(error)") 0044 } 0045 } 0046 } 0047 0048 extension NSDictionary: ResponseConvertible { 0049 public func response() -> Response { 0050 do { 0051 return try Response(status: .OK, json: self) 0052 } catch { 0053 return Response(error: "JSON serialization error: \(error)") 0054 } 0055 } 0056 } 0057 0058 extension NSArray: ResponseConvertible { 0059 public func response() -> Response { 0060 do { 0061 return try Response(status: .OK, json: self) 0062 } catch { 0063 return Response(error: "JSON serialization error: \(error)") 0064 } 0065 } 0066 }