Skip to content

Instantly share code, notes, and snippets.

View hhariri's full-sized avatar

Hadi Hariri hhariri

View GitHub Profile
task("stuff") {
// Do things
}
task("stuff") {
}
task("thing", "cheese", "oink", "wibble") {
json {
"name" json "fred"
"age" json 5
"address" json {
"firstLine" json "Buckingham Palace"
"town" json "London"
}
"friends" json array("name", "text", 23, 42)
}
class Demo : Build {
val domain = project(dir = "domain") {}
val core = project(dir = "core") {
dependencies += listOf(Dependencies.kotlin, Dependencies.spek)
}
override fun root() = project(dir = ".") {
aggregates(core, domain)
}
val userJson = json {
obj {
"firstName" to u.firstName
"lastName" to u.lastName
"banthaPoodoo" to ns
"age" to u.age
"inner" to obj {
"x" to 1
}
"empty" to obj {
json {
"name" .. "Mr. Jones"
"age" .. 5
"address" .. {
"number" .. 444
"line one" .. "some place over the rainbow"
}
"family".array(
{
"name" .. "Mrs. Jones"
Routes.get("/customer/10", {
val obj = object {
val name = "John"
}
response.send(obj, ContentType.ApplicationJson)
})
<?xml version=\"1.0\" encoding=\"UTF-8\"?><response><statusCode>200</statusCode><statusText>Test Complete</statusText><data><statusCode>200</statusCode><statusText>Test Complete</statusText><testId>130511_3N_P78</testId><runs>1</runs><fvonly>0</fvonly><remote></remote><testsExpected>2</testsExpected><location>Dulles_IE9</location><startTime>05/11/13 18:57:43</startTime><elapsed>178752</elapsed><completeTime>05/11/13 18:57:51</completeTime><testsCompleted>2</testsCompleted></data></response>
val server = AppServer()
Routes.get("/good",{ response.send("Well this means that routes now work!")})
Routes.get("/",{ response.send("Hello, how are you")})
"/customer" post { response.send("abc") }
resource public fun CustomerResources() {
"/customer" get {
}
"/customer" post {
resource "/customer" get { response.send("a....") }