Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Declarative Endpoint returns 404 when specifying body #2000

Closed
ccerbusca opened this issue Feb 18, 2023 · 0 comments · Fixed by #2005
Closed

Declarative Endpoint returns 404 when specifying body #2000

ccerbusca opened this issue Feb 18, 2023 · 0 comments · Fixed by #2005
Assignees
Labels
bug Something isn't working

Comments

@ccerbusca
Copy link
Contributor

ccerbusca commented Feb 18, 2023

When using the declarative endpoint feature and specifying a body type using the in operator, requests to that endpoint will always return a 404 Not Found error.

Small reproducer:

import zio.*
import zio.http.codec.HttpCodec.*
import zio.http.endpoint.*
import zio.http.{ Middleware, Server }
import zio.schema.{ DeriveSchema, Schema }

object Main extends ZIOAppDefault {

  case class Test(value: String)

  given Schema[Test] = DeriveSchema.gen[Test]

  val endpoint =
    Endpoint
      .post("test")
      .in[Test]
      .out[Test]
      .implement(ZIO.succeed)

  override def run =
    Server
      .serve(endpoint.toApp @@ Middleware.debug)
      .provide(
        Server.defaultWithPort(8080)
      )

}

with the following sample request:
image

Expected behaviour
Sending a correct post request to the /test endpoint should return a 200 OK response

Additional context
Happens on the latest snapshot of zio-http with Scala 3.2.2

@ccerbusca ccerbusca added the bug Something isn't working label Feb 18, 2023
@jdegoes jdegoes self-assigned this Feb 20, 2023
jdegoes added a commit to jdegoes/zio-http that referenced this issue Feb 21, 2023
@vigoo vigoo linked a pull request Feb 21, 2023 that will close this issue
@jdegoes jdegoes closed this as completed Feb 21, 2023
jdegoes added a commit that referenced this issue Feb 21, 2023
* fixes #2000, #2001

* only evaluate once
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants