izqui / Taylor

A lightweight library for writing HTTP web servers with Swift
MIT License
926 stars 79 forks source link

Hello, World example doesn't seem to work :( #44

Open jhoughjr opened 8 years ago

jhoughjr commented 8 years ago

The Hello, World example isn't working at all for me.

my code in app delegate, pasted from the docs: `import Cocoa import Taylor

@NSApplicationMain class AppDelegate: NSObject, NSApplicationDelegate {

@IBOutlet weak var window: NSWindow!

func applicationDidFinishLaunching(aNotification: NSNotification) {

    let server = Taylor.Server()

    server.get("/") { req, res in
        res.bodyString = "Hello, world!"
        return .Send
    }

    let port = 3002
    do {
        print("Starting server on port: \(port)")
        try server.serveHTTP(port: port, forever: true)
    } catch {
        print("Server start failed \(error)")
    }
}

`

The error is : Contextual type for closure argument list expects 3 arguments, but 2 were specified. I've tried for quite a while to get the format of the closure correct but to no avail. where can I find a working example so I can start using this?

Danappelxx commented 8 years ago

Hey there! It seems as though you're using the latest release instead of the master branch. Unfortunately development stalled in the middle of a large refactor, so although we updated the readme we didn't tag a new release. For now you can use the example in the readme from the previous release here.

let server = Taylor.Server()

server.get("/") {
    req, res, cb in

    res.bodyString = "Hello, world!"
    cb(.Send(req, res))
}

let port = 3002
do {
   print("Staring server on port: \(port)")
   try server.serveHTTP(port: port, forever: true)
} catch let e {
   print("Server start failed \(e)")
}
jhoughjr commented 8 years ago

I thought I had responded to this earlier, thanks for the assistance. I look forward to this project growing!

gabhi commented 8 years ago

Thanks @Danappelxx