softwaremill / softwaremill/tapir

[BUG] zio-http does not work with multipartBody[T]

Open
#1,595 2 comments 0 reactions 1 assignee View on GitHub

@kubinio123 is already working on this.

Since Mar 2, 2023.

Dominant language
Scala
Stars
1.5k
Forks
468
Avg merge
5h 37m
Merged PRs (30d)
34

Description

Tapir version: 0.19-M14

Scala version: Scala 2.13.6

Describe the bug

What is the problem?

zio-http with multipartBody[T] does not work. Server does not respond and it seems that logic is not activated.

How to reproduce?

package example

case class Test(input: String)

object ZioTestApp extends zio.App {

	import zio._
	import zio.magic._
	import zio.logging._
	import sttp.tapir.ztapir._
	import sttp.tapir.generic.auto._
	import zhttp.service.{EventLoopGroup, Server}
	import zhttp.service.server.ServerChannelFactory
	import sttp.tapir.server.ziohttp.ZioHttpInterpreter


	val testEndpoint = endpoint
		.post
		.in("api" / "test")
		.in(multipartBody[Test])
		.out(plainBody[String])

	def testLogic(input: Test) = for {
		_ <- log.info(s"simple call ${input}")
	} yield "ok"

	val testRoute = ZioHttpInterpreter()
		.toHttp(testEndpoint.zServerLogic(testLogic))

	val server = Server.port(9091) ++
		Server.paranoidLeakDetection ++
		Server.app(testRoute)

	val loggingLayer =
		Logging.console() >>>
			Logging.withRootLoggerName("test")

	override def run(args: List[String]): URIO[zio.ZEnv, ExitCode] = {
		server.make
			.use(_ =>
				log.info("server started") *> ZIO.never
			)
			.injectCustom(
				ServerChannelFactory.auto,
				EventLoopGroup.auto(4),
				loggingLayer
			)
			.exitCode
	}

}

Additional information

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.