Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiuszkierat committed Dec 31, 2024
1 parent dde904c commit 67760c5
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//> using dep com.softwaremill.sttp.tapir::tapir-core:1.11.11
//> using dep org.apache.pekko::pekko-stream:1.1.2
//> using dep org.typelevel::cats-effect:3.5.7
//> using dep com.softwaremill.sttp.client3::core:3.10.1
//> using dep com.softwaremill.sttp.client3::core:3.10.2
//> using dep com.softwaremill.sttp.client3::pekko-http-backend:3.10.1

package sttp.tapir.examples.streaming
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
//> using dep com.softwaremill.sttp.tapir::tapir-core:1.11.11
//> using dep com.softwaremill.sttp.tapir::tapir-play-server:1.11.11
//> using dep org.playframework::play-netty-server:3.0.6
//> using dep com.softwaremill.sttp.client3::core:3.10.1
//> using dep com.softwaremill.sttp.client3::core:3.10.2
//> using dep org.slf4j:slf4j-simple:2.0.16

package sttp.tapir.examples.streaming

Expand All @@ -18,11 +19,13 @@ import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Future
import sttp.model.{HeaderNames, MediaType, Part, StatusCode}
import sttp.tapir.*

import scala.concurrent.{ExecutionContext, Future}
import scala.util.*
import org.apache.pekko
import pekko.stream.scaladsl.{Flow, Source}
import pekko.util.ByteString
import sttp.tapir.server.play.PlayServerOptions

given ExecutionContext = ExecutionContext.global

Expand Down Expand Up @@ -51,15 +54,18 @@ val e = endpoint.post
.out(header[Long](HeaderNames.ContentLength))
.out(streamTextBody(PekkoStreams)(CodecFormat.TextPlain()))
.errorOut(plainBody[ErrorInfo])
.serverLogic((logic _).andThen(handleErrors))
.serverLogic(logic.andThen(handleErrors))


val routes = PlayServerInterpreter().toRoutes(e)
val routes = PlayServerInterpreter(PlayServerOptions.customiseInterceptors().serverLog(PlayServerOptions.defaultServerLog.logWhenReceived(true)
.logAllDecodeFailures(true)).options).toRoutes(e)

@main def playServer(): Unit =
import play.api.Configuration
import play.api.Mode
import play.core.server.ServerConfig


import java.io.File
import java.util.Properties

Expand All @@ -82,13 +88,13 @@ val routes = PlayServerInterpreter().toRoutes(e)
"play.server.websocket.periodic-keep-alive-max-idle" -> "infinite",
"play.server.max-content-length" -> "infinite",
"play.server.netty.log.wire" -> true,
"play.server.netty.option.child.tcpNoDelay" -> true,
"play.server.netty.option.child.SO_KEEPALIVE" -> false,
"play.server.pekko.requestTimeout" -> "5 seconds",
)
val serverConfig = ServerConfig(
rootDir = new File("."),
port = Some(9000),
sslPort = Some(9443),
sslPort = None,
address = "0.0.0.0",
mode = Mode.Dev,
properties = System.getProperties,
Expand Down
2 changes: 1 addition & 1 deletion perf-tests/src/main/scala/sttp/tapir/perf/play/Play.scala
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ object Tapir extends Endpoints {
(actorSystem: ActorSystem) => {
implicit val actorSystemForMaterializer: ActorSystem = actorSystem
implicit val ec: ExecutionContext = actorSystem.dispatcher
val serverOptions = buildOptions(PlayServerOptions.customiseInterceptors(), withServerLog)
val serverOptions = buildOptions(PlayServerInterpreter, withServerLog)
PlayServerInterpreter(serverOptions).toRoutes(
genEndpointsFuture(nRoutes)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ class PlayServerTest extends TestSuite {
def drainAkka(stream: AkkaStreams.BinaryStream): Future[Unit] =
stream.runWith(Sink.ignore).map(_ => ())

PlayServerOptions.customiseInterceptors().serverLog(PlayServerOptions.defaultServerLog.logWhenReceived(true)
.logAllDecodeFailures(true)).options

new ServerBasicTests(
createServerTest,
interpreter,
Expand Down

0 comments on commit 67760c5

Please sign in to comment.