-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b77572f
commit 3865580
Showing
3 changed files
with
113 additions
and
3 deletions.
There are no files selected for viewing
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
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
85 changes: 85 additions & 0 deletions
85
samples/ksp-sample/src/commonMain/kotlin/dev/programadorthi/routing/sample/Composables.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
package dev.programadorthi.routing.sample | ||
|
||
import androidx.compose.runtime.Composable | ||
import dev.programadorthi.routing.annotation.Body | ||
import dev.programadorthi.routing.annotation.Path | ||
import dev.programadorthi.routing.annotation.Route | ||
import dev.programadorthi.routing.core.application.Application | ||
import io.ktor.http.Parameters | ||
import io.ktor.util.Attributes | ||
|
||
@Route("/compose") | ||
@Composable | ||
fun compose() { | ||
println(">>>> I'm routing") | ||
} | ||
|
||
@Route(path = "/compose/{id}") | ||
@Composable | ||
fun compose(id: Double) { | ||
println(">>>> ID: $id") | ||
} | ||
|
||
@Route(path = "/composeNamed/{name}", name = "composeNamed") | ||
@Composable | ||
fun composeNamed(name: String) { | ||
println(">>>> name: $name") | ||
} | ||
|
||
@Route(path = "/composeCustom/{random}", name = "composeCustom") | ||
@Composable | ||
fun composeCustom(@Path("random") value: String) { | ||
println(">>>> value: $value") | ||
} | ||
|
||
@Route(path = "/composeOptional/{id?}") | ||
@Composable | ||
fun composeOptional(id: Char?) { | ||
println(">>>> Optional ID: $id") | ||
} | ||
|
||
@Route(path = "/composeTailcard/{param...}") | ||
@Composable | ||
fun composeTailcard(param: List<String>?) { | ||
println(">>>> Tailcard params: $param") | ||
} | ||
|
||
@Route("/compose-with-body") | ||
@Composable | ||
fun composeWithBody(@Body user: User) { | ||
println(">>>> with body $user") | ||
} | ||
|
||
@Route("/compose-with-null-body") | ||
@Composable | ||
fun composeWithNullBody(@Body user: User?) { | ||
println(">>>> null body $user") | ||
} | ||
|
||
@Route("/compose", method = "PUSH") | ||
@Composable | ||
fun composeByPushMethod() { | ||
println(">>>> I'm pushing a route") | ||
} | ||
|
||
@Route("/compose/{part1}/{part2}") | ||
@Composable | ||
fun composeMultiParameters(part1: Int, part2: String) { | ||
println(">>>> Parts: $part1 and $part2") | ||
} | ||
|
||
@Route("/compose-call/{part1}/{part2}") | ||
@Composable | ||
fun composeCallParameters( | ||
application: Application, | ||
parameters: Parameters, | ||
attributes: Attributes, | ||
) { | ||
println( | ||
""" | ||
>>>> application: $application | ||
>>>> parameters: $parameters | ||
>>>> attributes: $attributes | ||
""".trimIndent() | ||
) | ||
} |