Skip to content

Commit

Permalink
Fix api
Browse files Browse the repository at this point in the history
  • Loading branch information
marychatte committed Nov 8, 2024
1 parent f7429d9 commit 37f573a
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public fun Route.sse(path: String, handler: suspend ServerSSESession.() -> Unit)
*
* @see ServerSSESession
*/
public fun Route.sse(handler: suspend ServerSSESession.() -> Unit): Unit = processSSEWithoutSerialization(null, handler)
public fun Route.sse(handler: suspend ServerSSESession.() -> Unit): Unit = processSSEWithoutSerialization(handler)

/**
* Adds a route to handle Server-Sent Events (SSE) at the specified [path] using the provided [handler].
Expand Down Expand Up @@ -99,7 +99,7 @@ public fun Route.sse(handler: suspend ServerSSESession.() -> Unit): Unit = proce
*/
public fun Route.sse(
path: String,
serialize: (TypeInfo, Any) -> String = { _, it -> it.toString() },
serialize: (TypeInfo, Any) -> String,
handler: suspend ServerSSESessionWithSerialization.() -> Unit
) {
route(path, HttpMethod.Get) {
Expand Down Expand Up @@ -136,14 +136,13 @@ public fun Route.sse(
* @see ServerSSESessionWithSerialization
*/
public fun Route.sse(
serialize: (TypeInfo, Any) -> String = { _, it -> it.toString() },
serialize: (TypeInfo, Any) -> String,
handler: suspend ServerSSESessionWithSerialization.() -> Unit
): Unit = processSSEWithSerialization(serialize, handler)

private fun Route.processSSEWithoutSerialization(
serialize: ((TypeInfo, Any) -> String)?,
handler: suspend ServerSSESession.() -> Unit
) = processSSE(serialize, handler)
) = processSSE(null, handler)

private fun Route.processSSEWithSerialization(
serialize: ((TypeInfo, Any) -> String),
Expand Down

0 comments on commit 37f573a

Please sign in to comment.