sttp.tapir.server.interpreter.RequestBody.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of tapir-server_native0.5_2.12 Show documentation
Show all versions of tapir-server_native0.5_2.12 Show documentation
Core classes for server interpreters & interceptors
package sttp.tapir.server.interpreter
import sttp.capabilities.Streams
import sttp.model.Part
import sttp.tapir.model.ServerRequest
import sttp.tapir.{FileRange, RawBodyType, RawPart}
trait RequestBody[F[_], S] {
val streams: Streams[S]
def toRaw[R](serverRequest: ServerRequest, bodyType: RawBodyType[R], maxBytes: Option[Long]): F[RawValue[R]]
def toStream(serverRequest: ServerRequest, maxBytes: Option[Long]): streams.BinaryStream
}
case class RawValue[R](value: R, createdFiles: Seq[FileRange] = Nil)
object RawValue {
def fromParts(parts: Seq[RawPart]): RawValue[Seq[RawPart]] =
RawValue(parts, parts collect { case _ @Part(_, f: FileRange, _, _) => f })
}