commonMain.dev.programadorthi.routing.events.resources.EventResourceRouting.kt Maven / Gradle / Ivy
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