@@ -7,6 +7,9 @@ import dev.programadorthi.routing.core.application.Application
77import dev.programadorthi.routing.core.application.ApplicationCall
88import io.ktor.http.Parameters
99import io.ktor.util.Attributes
10+ import kotlin.to
11+
12+ val invoked = mutableMapOf<String , List <Any ?>>()
1013
1114data class User (
1215 val id : Int ,
@@ -15,73 +18,73 @@ data class User(
1518
1619@Route(" /path" )
1720fun execute () {
18- println ( " >>>> I'm routing " )
21+ invoked + = " /path " to emptyList( )
1922}
2023
2124@Route(path = " /path/{id}" )
2225fun execute (id : Double ) {
23- println ( " >>>> ID: $id " )
26+ invoked + = " /path/{id} " to listOf (id )
2427}
2528
2629@Route(path = " /named/{name}" , name = " named" )
2730fun named (name : String ) {
28- println ( " >>>> name: $ name" )
31+ invoked + = " /named/{ name} " to listOf (name )
2932}
3033
3134@Route(path = " /custom/{random}" , name = " custom" )
3235fun custom (
3336 @Path(" random" ) value : String
3437) {
35- println ( " >>>> value: $ value" )
38+ invoked + = " /custom/{random} " to listOf ( value)
3639}
3740
3841@Route(path = " /optional/{id?}" )
3942fun optional (id : Char? ) {
40- println ( " >>>> Optional ID: $id " )
43+ invoked + = " /optional/{id?} " to listOf (id )
4144}
4245
4346@Route(path = " /tailcard/{param...}" )
4447fun tailcard (param : List <String >? ) {
45- println ( " >>>> Tailcard params: $param " )
48+ invoked + = " /tailcard/{param...} " to (param ? : emptyList() )
4649}
4750
4851@Route(regex = " .+/hello" )
4952fun regex1 () {
50- println ( " >>>> Routing with regex " )
53+ invoked + = " .+/hello " to listOf ( )
5154}
5255
5356@Route(regex = " /(?<number>\\ d+)" )
5457fun regex2 (number : Int ) {
55- println ( " >>>> Routing with regex to number: $number " )
58+ invoked + = " /(?<number> \\ d+) " to listOf ( number)
5659}
5760
5861@Route(" /with-body" )
5962fun withBody (
6063 @Body user : User
6164) {
62- println ( " >>>> with body $ user" )
65+ invoked + = " /with- body" to listOf ( user)
6366}
6467
6568@Route(" /with-null-body" )
6669fun withNullBody (
6770 @Body user : User ?
6871) {
69- println ( " >>>> null body $ user" )
72+ invoked + = " /with-null- body" to listOf ( user)
7073}
7174
7275@Route(" /path" , method = " PUSH" )
7376fun byPushMethod () {
74- println ( " >>>> I'm pushing a route " )
77+ invoked + = " /path " to listOf ( " PUSH " )
7578}
7679
7780@Route(" /path/{part1}/{part2}" )
7881fun multiParameters (part1 : Int , part2 : String ) {
79- println ( " >>>> Parts: $ part1 and $ part2" )
82+ invoked + = " /path/{ part1}/{part2} " to listOf (part1, part2)
8083}
8184
8285@Route(" /call" )
8386fun call (call : ApplicationCall ) {
84- println ( " >>>> call: $ call" )
87+ invoked + = " / call" to listOf (call )
8588}
8689
8790@Route(" /call/{part1}/{part2}" )
@@ -90,11 +93,5 @@ fun callParameters(
9093 parameters : Parameters ,
9194 attributes : Attributes ,
9295) {
93- println (
94- """
95- >>>> application: $application
96- >>>> parameters: $parameters
97- >>>> attributes: $attributes
98- """ .trimIndent()
99- )
96+ invoked + = " /call/{part1}/{part2}" to listOf (application, parameters, attributes)
10097}
0 commit comments