diff --git a/airframe-http-codegen/src/main/scala/wvlet/airframe/http/codegen/HttpClientIR.scala b/airframe-http-codegen/src/main/scala/wvlet/airframe/http/codegen/HttpClientIR.scala index c6502a189..0382093d0 100644 --- a/airframe-http-codegen/src/main/scala/wvlet/airframe/http/codegen/HttpClientIR.scala +++ b/airframe-http-codegen/src/main/scala/wvlet/airframe/http/codegen/HttpClientIR.scala @@ -13,16 +13,17 @@ */ package wvlet.airframe.http.codegen -import java.util.Locale import wvlet.airframe.http.Router.unwrapFuture -import wvlet.airframe.http.{HttpMethod, Router, RxRouter} import wvlet.airframe.http.codegen.RouteAnalyzer.RouteAnalysisResult import wvlet.airframe.http.codegen.client.HttpClientGenerator import wvlet.airframe.http.codegen.client.HttpClientGenerator.fullTypeNameOf +import wvlet.airframe.http.router.Route +import wvlet.airframe.http.{HttpMethod, Router, RxRouter, ServerSentEvent} import wvlet.airframe.rx.Rx -import wvlet.airframe.surface.{GenericSurface, HigherKindedTypeSurface, MethodParameter, Parameter, Surface, TypeName} +import wvlet.airframe.surface.* import wvlet.log.LogSupport -import wvlet.airframe.http.router.{HttpRequestMapper, Route} + +import java.util.Locale /** * Generate an intermediate representation (IR) of Scala HTTP client code from a given airframe-http interface @@ -189,7 +190,12 @@ object HttpClientIR extends LogSupport { val isRxResponse = returnType.rawType.isAssignableFrom(classOf[Rx[_]]) && returnType.typeArgs.size == 1 if (isRxResponse) { // for methods returning Rx[A], extract A - returnType.typeArgs(0) + val tpe = returnType.typeArgs(0) + if (tpe.rawType == classOf[ServerSentEvent]) { + // For SSE, return empty result as the events will be handled by the event handler + Surface.of[Unit] + } else + tpe } else { returnType } diff --git a/airframe-http-codegen/src/main/scala/wvlet/airframe/http/codegen/client/RPCClientGenerator.scala b/airframe-http-codegen/src/main/scala/wvlet/airframe/http/codegen/client/RPCClientGenerator.scala index 453a506a3..ddb4ce1f7 100644 --- a/airframe-http-codegen/src/main/scala/wvlet/airframe/http/codegen/client/RPCClientGenerator.scala +++ b/airframe-http-codegen/src/main/scala/wvlet/airframe/http/codegen/client/RPCClientGenerator.scala @@ -12,7 +12,8 @@ * limitations under the License. */ package wvlet.airframe.http.codegen.client -import wvlet.airframe.http.{Http, HttpMethod} +import wvlet.airframe.http.HttpMessage.Response +import wvlet.airframe.http.{Http, HttpMethod, ServerSentEvent} import wvlet.airframe.http.codegen.HttpClientIR import wvlet.airframe.http.codegen.HttpClientIR.{ClientMethodDef, ClientServiceDef} import wvlet.airframe.http.codegen.client.HttpClientGenerator.RichSurface