tapir icon indicating copy to clipboard operation
tapir copied to clipboard

Zio-http: Set method on route handlers to prevent overlap

Open amumurst opened this issue 7 months ago • 2 comments

This is attempting to fix the issue where you can not add overlapping method for zio-http. If I add two methods

GET /foo/bar/ and POST /foo/bar zio-http will currently mark them as duplicates in zio-http since the method is hard coded to be Any in the ZioHttpInterpreter

Setting these will trigger: https://github.com/zio/zio-http/blob/443db4097f33d348d293ef3f55abdc5cb7198d6d/zio-http/shared/src/main/scala/zio/http/Routes.scala#L280

Which has called unique from: https://github.com/zio/zio-http/blob/443db4097f33d348d293ef3f55abdc5cb7198d6d/zio-http/shared/src/main/scala/zio/http/Routes.scala#L324

by calling the method in which checks equals on method: https://github.com/zio/zio-http/blob/443db4097f33d348d293ef3f55abdc5cb7198d6d/zio-http/shared/src/main/scala/zio/http/RoutePattern.scala#L130

Which is why they are marked as overlapping even when they have different methods.

It might well be that this is too simple and there is no real good solution for this; but hoping that its just an oversight 🙏

(should resolve some of the issues mentioned here? https://github.com/softwaremill/tapir/blob/master/doc/server/ziohttp.md?plain=1#L59)

amumurst avatar Sep 24 '25 11:09 amumurst

Tests fails so it seems it was not that simple..

amumurst avatar Sep 24 '25 12:09 amumurst

I think there might a step later in the pattern-generation where we combine patterns for multiple endpoints, so that if you have GET /foo and POST /foo Tapir-endpoints, you end up with a single ZIO-HTTP pattern. So maybe that's the problem. But generally generating these patterns correctly has been definitely non-trivial (and still is lacking in some respects)

adamw avatar Sep 25 '25 13:09 adamw