-
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
267c196
commit f3be4ee
Showing
5 changed files
with
205 additions
and
49 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
ksp/core-annotations/common/src/dev/programadorthi/routing/annotation/TypeSafeRoute.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,13 @@ | ||
package dev.programadorthi.routing.annotation | ||
|
||
import kotlin.reflect.KClass | ||
|
||
@Target( | ||
AnnotationTarget.CLASS, | ||
AnnotationTarget.CONSTRUCTOR, | ||
AnnotationTarget.FUNCTION, | ||
) | ||
public annotation class TypeSafeRoute( | ||
val type: KClass<*>, | ||
val method: String = "", | ||
) |
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
46 changes: 46 additions & 0 deletions
46
resources/common/test/dev/programadorthi/routing/resources/Resources.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,46 @@ | ||
package dev.programadorthi.routing.resources | ||
|
||
import dev.programadorthi.routing.annotation.Body | ||
import dev.programadorthi.routing.annotation.TypeSafeRoute | ||
import dev.programadorthi.routing.resources.helper.Path | ||
|
||
internal val invoked = mutableMapOf<String, List<Any?>>() | ||
|
||
internal data class User( | ||
val id: Int, | ||
val name: String, | ||
) | ||
|
||
@TypeSafeRoute(Path::class) | ||
fun execute() { | ||
invoked += "/path" to emptyList() | ||
} | ||
|
||
@TypeSafeRoute(Path.Id::class) | ||
fun execute(pathId: Path.Id) { | ||
invoked += "/path/{id}" to listOf(pathId) | ||
} | ||
|
||
@TypeSafeRoute(Path::class, method = "PUSH") | ||
fun executePush() { | ||
invoked += "/path-push" to emptyList() | ||
} | ||
|
||
@TypeSafeRoute(Path::class, method = "POST") | ||
internal fun executePost( | ||
@Body user: User | ||
) { | ||
invoked += "/path-post" to listOf(user) | ||
} | ||
|
||
@TypeSafeRoute(Path::class, method = "custom") | ||
internal fun executeCustom( | ||
@Body user: User | ||
) { | ||
invoked += "/path-custom" to listOf(user) | ||
} | ||
|
||
@TypeSafeRoute(Path.Optional::class) | ||
internal fun executeOptional(optional: Path.Optional) { | ||
invoked += "/path-optional" to listOf(optional) | ||
} |
Oops, something went wrong.