
Code-generates safe URIs from type-safe arguments using KSP. Supports path and query parameters and includes modifiers for query and unescaped parameters. Experimental phase.
Generates compile-time safe (escaped) URI paths from functions in Kotlin using KSP. Only path and query parameters are supported for now.
@UriProvider
interface MyTestPaths {
@UriTemplate("example/{parameter}")
fun myUri(parameter: String, @Query extra: String): String
}
fun main() {
println(KuriMyTestPaths.myUri("Hello World", "test"))
// Output: example/Hello%20World?extra=test
}implementation("se.ade.kuri.api:kuri-api:0.1.2")
ksp("se.ade.kuri.processor:kuri-processor:0.1.2")
@UriProvider, and define functions annotated with @UriTemplate, where placeholders match function arguments:
@UriProvider
interface MyTestUris {
@UriTemplate("path/{parameter}/example")
fun myUri(parameter: String): String
}object KuriMyTestUris: MyTestUris {
fun myUri(parameter: String): String = "... generated code ..."
}val uriString = KuriMyTestUris.myUri("test")which will allow you to construct safe URIs with the supplied parameters.
@UriTemplate("path/{parameter}/example")
fun myUri(parameter: String, @Query foo: String?): String
Lists are supported, and will be output as multiple entries of the same key, e.g. ?foo=bar&foo=baz.
@UriTemplate("path/{parameter}/example")
fun myUri(parameter: String, @Query foo: List<String>): String
@UriTemplate("api/{path}/example")
fun myUri(@Unescaped path: String): String
Generates compile-time safe (escaped) URI paths from functions in Kotlin using KSP. Only path and query parameters are supported for now.
@UriProvider
interface MyTestPaths {
@UriTemplate("example/{parameter}")
fun myUri(parameter: String, @Query extra: String): String
}
fun main() {
println(KuriMyTestPaths.myUri("Hello World", "test"))
// Output: example/Hello%20World?extra=test
}implementation("se.ade.kuri.api:kuri-api:0.1.2")
ksp("se.ade.kuri.processor:kuri-processor:0.1.2")
@UriProvider, and define functions annotated with @UriTemplate, where placeholders match function arguments:
@UriProvider
interface MyTestUris {
@UriTemplate("path/{parameter}/example")
fun myUri(parameter: String): String
}object KuriMyTestUris: MyTestUris {
fun myUri(parameter: String): String = "... generated code ..."
}val uriString = KuriMyTestUris.myUri("test")which will allow you to construct safe URIs with the supplied parameters.
@UriTemplate("path/{parameter}/example")
fun myUri(parameter: String, @Query foo: String?): String
Lists are supported, and will be output as multiple entries of the same key, e.g. ?foo=bar&foo=baz.
@UriTemplate("path/{parameter}/example")
fun myUri(parameter: String, @Query foo: List<String>): String
@UriTemplate("api/{path}/example")
fun myUri(@Unescaped path: String): String