This file contains 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
fun main(args: Array<String>) { | |
val httpClient = HttpClient() | |
httpClient.get("http://site.com") { response -> Unit | |
println(response.body) | |
} | |
} |
This file contains 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
fun main(args: Array<String>) { | |
val httpClient = HttpClient() | |
httpClient.get("http://site.com") { | |
println(body) | |
} | |
} | |
This file contains 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
var o = Observable.from(arrayListOf("1", "2", "3", "4")) | |
o.subscribe( | |
onNext = { result -> println(result)}, | |
onError = { (error) -> println(error)}, | |
onComplete = { () -> println("Complete")} | |
) | |
This file contains 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
val http = EasyHttp() | |
http.post( | |
url = "http://httpbin.org/post", | |
contents = Customer(name = "Joe", email = "joe@gmail.com"), | |
headers = RequestHeaders(contentType = "application/x-www-form-urlencoded"), | |
callback = { assertEquals(StatusCode.OK, statusCode) } | |
) |
This file contains 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
val server = AppServer() | |
server.serveStaticFilesFromFolder("/public") | |
server.useBasicAuthentication("private-area", path = "/private", callback = { (user, pass) -> user == pass }) | |
server.get("/headers", { | |
request.rawHeaders.forEach { | |
println("${it.first}: ${it.second}") | |
} | |
response.send("Hello!") |
This file contains 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
var REVEALING = function () { | |
var privateProp = "Log"; | |
var PIVALUE = 3.14; | |
log = function (message) { | |
console.log(privateProp + ": " + message); | |
}; |
This file contains 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
fun String.extendingStrings() { | |
} | |
data class ThisDto(val nameProperty: String, val emailProperty: String) // DTO | |
// gives me hashCode, toString, equal operator (comparing properties) and two immutable properties name, email | |
This file contains 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
public class PascalHumanizerTests(): Spek() {{ | |
val data = listOf( | |
"ThisIsATest" to "This Is A Test", | |
"ThisIsAnotherTest" to "This Is Another Test" | |
) | |
given(data) { | |
on("calling humanize", { | |
val actual = it.component1().humanize() |
This file contains 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
public class PascalHumanizerTests(): Spek() {{ | |
val data = listOf( | |
"ThisIsATest" to "This Is A Test", | |
"ThisIsAnotherTest" to "This Is Another Test" | |
) | |
givenData(data) { | |
val (input, expected) = it | |
on("calling humanize", { |
This file contains 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
public class CustomerController [Inject] (val customerRepository: CustomerRepository) { | |
fun list() { | |
customerRepository.getAll() | |
} | |
} |
OlderNewer