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

Nested routes serve routes on all nested paths #3243

Open
amumurst opened this issue Dec 9, 2024 · 7 comments · May be fixed by #3300
Open

Nested routes serve routes on all nested paths #3243

amumurst opened this issue Dec 9, 2024 · 7 comments · May be fixed by #3300
Labels
💎 Bounty bug Something isn't working

Comments

@amumurst
Copy link

amumurst commented Dec 9, 2024

Describe the bug
The feature of nesting routes is exposing paths on both the original path, and on the nested path.
https://zio.dev/zio-http/reference/routing/routes#nested-routes

To Reproduce
I found it by curl-ing my app, but here is a reproducer using both the direct request syntax and calling the server directly

//> using dep "dev.zio::zio-http:3.0.1"
import zio.*
import zio.http.*
import zio.http.codec.PathCodec

object HelloWorld extends ZIOAppDefault:
  val routed = PathCodec.literal("foo") / Routes(
    Method.GET / "hello" -> handler(Response.text("World"))
  )
  val hello = Request.get("http://localhost:8080/hello")
  val fooHello = Request.get("http://localhost:8080/foo/hello")
  override def run = {
    for {
      res1 <- routed.runZIO(hello).debug //Gives OK
      res2 <- routed.runZIO(fooHello).debug //Gives OK
      p <- Server.serve(routed).forkDaemon
      res3 <- Client.batched(hello).debug //Gives OK
      res4 <- Client.batched(fooHello).debug //Gives OK
      _ <- p.interrupt
    } yield ()
  }.provide(Server.default ++ Client.default)

Expected behaviour
Only the requests to fooHello respond with 200 OK, with the requests to hello giving 404.

@amumurst amumurst added the bug Something isn't working label Dec 9, 2024
@jdegoes
Copy link
Member

jdegoes commented Jan 22, 2025

/bounty $100

Copy link

algora-pbc bot commented Jan 22, 2025

💎 $100 bounty • ZIO

Steps to solve:

  1. Start working: Comment /attempt #3243 with your implementation plan
  2. Submit work: Create a pull request including /claim #3243 in the PR body to claim the bounty
  3. Receive payment: 100% of the bounty is received 2-5 days post-reward. Make sure you are eligible for payouts

Thank you for contributing to zio/zio-http!

Add a bountyShare on socials

Attempt Started (GMT+0) Solution
🟢 @deekshatomer Feb 11, 2025, 8:59:59 PM #3300

@kovstas
Copy link

kovstas commented Feb 1, 2025

I couldn't reproduce it in the main branch, it seems that this issue was fixed in this PR #3121

@987Nabil
Copy link
Contributor

987Nabil commented Feb 8, 2025

closed by #3121

@987Nabil 987Nabil closed this as completed Feb 8, 2025
@987Nabil 987Nabil reopened this Feb 8, 2025
@deekshatomer
Copy link

deekshatomer commented Feb 11, 2025

Hi @987Nabil

I noticed that this issue was recently reopened after a fix attempt. Is this issue still open for contributions? I would love to work on it if possible.

Thank

@deekshatomer
Copy link

deekshatomer commented Feb 11, 2025

/attempt #3243

deekshatomer pushed a commit to deekshatomer/zio-http that referenced this issue Feb 11, 2025
deekshatomer pushed a commit to deekshatomer/zio-http that referenced this issue Feb 11, 2025
deekshatomer pushed a commit to deekshatomer/zio-http that referenced this issue Feb 11, 2025
deekshatomer added a commit to deekshatomer/zio-http that referenced this issue Feb 12, 2025
@deekshatomer deekshatomer linked a pull request Feb 12, 2025 that will close this issue
Copy link

algora-pbc bot commented Feb 12, 2025

💡 @deekshatomer submitted a pull request that claims the bounty. You can visit your bounty board to reward.

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

Successfully merging a pull request may close this issue.

5 participants