commonMain.dev.programadorthi.routing.events.resources.EventResourceRouting.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of events-resources-jvm Show documentation
Show all versions of events-resources-jvm Show documentation
An extensible and multiplatform routing system powered by Ktor
The newest version!
package dev.programadorthi.routing.events.resources
import dev.programadorthi.routing.core.Routing
import dev.programadorthi.routing.core.application.ApplicationCall
import dev.programadorthi.routing.core.application.plugin
import dev.programadorthi.routing.events.emitEvent
import dev.programadorthi.routing.events.redirectToEvent
import kotlinx.serialization.serializer
public inline fun Routing.emitEvent(resource: T) {
val format = plugin(EventResources).resourcesFormat
val serializer = serializer()
emitEvent(
name = format.encodeToPathPattern(serializer),
parameters = format.encodeToParameters(serializer, resource),
)
}
public inline fun ApplicationCall.redirectTo(resource: T) {
val format = application.plugin(EventResources).resourcesFormat
val serializer = serializer()
redirectToEvent(
name = format.encodeToPathPattern(serializer),
parameters = format.encodeToParameters(serializer, resource),
)
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy