From 1520abd565888bc88853dae7c68ed41ec3067101 Mon Sep 17 00:00:00 2001 From: Philippe Simons Date: Fri, 6 Sep 2019 14:49:36 +0200 Subject: [PATCH] ... --- .../kotlin/net/volcanomobile/weservsdk/Weserv.kt | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/kotlin/net/volcanomobile/weservsdk/Weserv.kt b/src/main/kotlin/net/volcanomobile/weservsdk/Weserv.kt index 0961c68..b231efd 100644 --- a/src/main/kotlin/net/volcanomobile/weservsdk/Weserv.kt +++ b/src/main/kotlin/net/volcanomobile/weservsdk/Weserv.kt @@ -13,10 +13,7 @@ data class Weserv internal constructor( val crop: Crop? ) -fun weserv(lambda: WeservBuilder.() -> Unit) = - WeservBuilder().apply(lambda).build() - -fun Weserv.buildUrl() = +private fun Weserv.buildUrl() = StringBuilder(BASE_URL).apply { append(URLEncoder.encode(url, "UTF-8")) @@ -33,4 +30,9 @@ fun Weserv.buildUrl() = if (crop != null) append(crop.toQueryString()) - }.toString() \ No newline at end of file + }.toString() + + +// DSL public entry point +fun weserv(lambda: WeservBuilder.() -> Unit) = + WeservBuilder().apply(lambda).build().buildUrl() \ No newline at end of file