Skip to content

Instantly share code, notes, and snippets.

@wess
Created November 4, 2016 16:19
Show Gist options
  • Save wess/25471f5a4cbecc8b9c8443f4365cd1a1 to your computer and use it in GitHub Desktop.
Save wess/25471f5a4cbecc8b9c8443f4365cd1a1 to your computer and use it in GitHub Desktop.
import Vapor
let root = Droplet()
root.get { req in return try root.view.make("welcome", []) }
root.group("v1") { v1 in
v1.group("prefs") { prefs in
let controller = PrefsController()
prefs.get("index", controller.index)
prefs.get("update", controller.update)
}
}
root.run()
@wess
Copy link
Author

wess commented Nov 4, 2016

Error:

Output:
Compile Swift Module 'App' (3 sources)
/Users/wess/Development/Nudge/services/Sources/App/main.swift:10:11: error: argument labels '(_:, :)' do not match any available overloads
prefs.get("index", controller.index)
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/wess/Development/Nudge/services/Sources/App/main.swift:10:11: note: overloads for 'get' exist with these partially matching parameter lists: (String, handler: @escaping (Request) throws -> ResponseRepresentable), (W0.Type, handler: @escaping (Request, W0) throws -> ResponseRepresentable)
prefs.get("index", controller.index)
^
/Users/wess/Development/Nudge/services/Sources/App/main.swift:11:11: error: argument labels '(
:, _:)' do not match any available overloads
prefs.get("update", controller.update)
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/wess/Development/Nudge/services/Sources/App/main.swift:11:11: note: overloads for 'get' exist with these partially matching parameter lists: (String, handler: @escaping (Request) throws -> ResponseRepresentable), (W0.Type, handler: @escaping (Request, W0) throws -> ResponseRepresentable)
prefs.get("update", controller.update)
^

@wess
Copy link
Author

wess commented Nov 4, 2016

import Vapor
import HTTP

final class PrefsController {
func index(_ request: Request) throws -> ResponseRepresentable {
return "Hello index"
}

func update(_ request: Request) throws -> ResponseRepresentable {
    return "Hello update"
}

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment