Skip to content

skyline75489/Honeymoon

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Honeymoon

A tiny web framework written in Swift 2.0, built on top of GCDWebServer and GRMustache.

Usage

Honeymoon itself is heavily inspired by Flask. At this moment, Honeymoon provides these following APIs:

let app = Honeymoon()

Basic Reponse

app.get("/") { req in
    return "Honeymoon started."
}

Paramaters in URL

app.get("/list/<userId>") { req in
    let userId = req.params!["userId"]!
    return "list\(userId)"
}

HTML Template

app.get("/testTemplate") { req in
    return app.renderTemplate("Test", data: ["name": "Chester","value": 10000, "taxed_value": 10000 - (10000 * 0.4), "in_ca": true])
}

Form

app.post("/post") { req in
    let c = req.form!["content"]!
    return "Content: \(c)"
}

Redirect

app.get("/testRedirect") { req in
    return app.redirect("/target")
}

Try it out

Currently there's a bug in Xcode when trying to use Swift framework in OS X command line application. So the example code is now in the tests.

Clone the project , use pod install to install the dependencies. Open the generated xcworkspace file and use Cmd + U to run the test. Go to localhost:8000 and that's it.

License

The MIT License

About

A tiny Swift web framework, written in Swift 2.0

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published