1
1
//> using dep com.softwaremill.sttp.tapir::tapir-core:1.11.11
2
2
//> using dep com.softwaremill.sttp.tapir::tapir-play-server:1.11.11
3
3
//> using dep org.playframework::play-netty-server:3.0.6
4
- //> using dep com.softwaremill.sttp.client3::core:3.10.1
4
+ //> using dep com.softwaremill.sttp.client3::core:3.10.2
5
+ //> using dep org.slf4j:slf4j-simple:2.0.16
5
6
6
7
package sttp .tapir .examples .streaming
7
8
@@ -18,11 +19,13 @@ import scala.concurrent.ExecutionContext.Implicits.global
18
19
import scala .concurrent .Future
19
20
import sttp .model .{HeaderNames , MediaType , Part , StatusCode }
20
21
import sttp .tapir .*
22
+
21
23
import scala .concurrent .{ExecutionContext , Future }
22
24
import scala .util .*
23
25
import org .apache .pekko
24
26
import pekko .stream .scaladsl .{Flow , Source }
25
27
import pekko .util .ByteString
28
+ import sttp .tapir .server .play .PlayServerOptions
26
29
27
30
given ExecutionContext = ExecutionContext .global
28
31
@@ -51,15 +54,18 @@ val e = endpoint.post
51
54
.out(header[Long ](HeaderNames .ContentLength ))
52
55
.out(streamTextBody(PekkoStreams )(CodecFormat .TextPlain ()))
53
56
.errorOut(plainBody[ErrorInfo ])
54
- .serverLogic((logic _).andThen(handleErrors))
57
+ .serverLogic(logic.andThen(handleErrors))
58
+
55
59
56
- val routes = PlayServerInterpreter ().toRoutes(e)
60
+ val routes = PlayServerInterpreter (PlayServerOptions .customiseInterceptors().serverLog(PlayServerOptions .defaultServerLog.logWhenReceived(true )
61
+ .logAllDecodeFailures(true )).options).toRoutes(e)
57
62
58
63
@ main def playServer (): Unit =
59
64
import play .api .Configuration
60
65
import play .api .Mode
61
66
import play .core .server .ServerConfig
62
67
68
+
63
69
import java .io .File
64
70
import java .util .Properties
65
71
@@ -82,13 +88,13 @@ val routes = PlayServerInterpreter().toRoutes(e)
82
88
" play.server.websocket.periodic-keep-alive-max-idle" -> " infinite" ,
83
89
" play.server.max-content-length" -> " infinite" ,
84
90
" play.server.netty.log.wire" -> true ,
85
- " play.server.netty.option.child.tcpNoDelay " -> true ,
91
+ " play.server.netty.option.child.SO_KEEPALIVE " -> false ,
86
92
" play.server.pekko.requestTimeout" -> " 5 seconds" ,
87
93
)
88
94
val serverConfig = ServerConfig (
89
95
rootDir = new File (" ." ),
90
96
port = Some (9000 ),
91
- sslPort = Some ( 9443 ) ,
97
+ sslPort = None ,
92
98
address = " 0.0.0.0" ,
93
99
mode = Mode .Dev ,
94
100
properties = System .getProperties,
0 commit comments