Last active
December 21, 2015 21:59
-
-
Save hhariri/6372080 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
data class Customer(val name: String, val email: String, val country: String) | |
val customerList = object : ArrayList<Customer>() { | |
} | |
fun main(args: Array<String>) { | |
// fill up some dummy customers | |
customerList.add(Customer("Joe Smith", "[email protected]", "UK")) | |
customerList.add(Customer("Jack Jones", "[email protected]", "US")) | |
customerList.add(Customer("Maria Gonzalez", "[email protected]", "Spain")) | |
// create server | |
val appServer = AppServer() | |
// enable content negotiation | |
appServer.negotiateContent() | |
// setup routes | |
appServer.get("/customers", listCustomers) | |
appServer.get("/customer/:id", getCustomerById) | |
appServer.post("/customer", createCustomer) | |
// start server | |
appServer.start() | |
} | |
// implement different route handlers | |
val listCustomers : RouteHandler.() -> Unit = { | |
response.send(customerList) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment