We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
When I am nesting routes as described at https://zio.dev/zio-http/dsl/routes it works until I need call handleError.
handleError
This server:
val routes = literal("to") / Routes( Method.GET / "other" -> handler(ZIO.fail(MyErrors.IdFormatError)), Method.GET / "do" / string("id") -> handler { (id:String, _: Request) => Response.text(s"GET /to/do/${id}") } ).handleError(_ match case MyErrors.IdFormatError => Response.badRequest ) def run = Server.serve(routes.toHttpApp).provide(Server.defaultWithPort(8090)) enum MyErrors: case IdFormatError
When started and invoked curl -i http://localhost:8090/to/do/45 outputs:
curl -i http://localhost:8090/to/do/45
HTTP/1.1 500 Internal Server Error warning: 199 ZIO HTTP "Exception in thread "zio-fiber-37" java.lang.RuntimeException: Expected path segment "do" but found " content-length: 0
But when the route leading to error (that I have to deal with) is removed:
val routes = literal("to") / Routes( Method.GET / "do" / string("id") -> handler { (id:String, _: Request) => Response.text(s"GET /to/do/${id}") } ) def run = Server.serve(routes.toHttpApp).provide(Server.defaultWithPort(8090))
Everything works fine and the result of curl -i http://localhost:8090/to/do/45 is:
HTTP/1.1 200 OK content-type: text/plain content-length: 18 GET /to/do/45
The text was updated successfully, but these errors were encountered:
/bounty $75 for fix and reproducer test case.
Sorry, something went wrong.
/attempt #2823
/claim #2823
Thank you for contributing to zio/zio-http!
Add a bounty • Share on socials
No branches or pull requests
When I am nesting routes as described at https://zio.dev/zio-http/dsl/routes it works until I need call
handleError
.This server:
When started and invoked
curl -i http://localhost:8090/to/do/45
outputs:But when the route leading to error (that I have to deal with) is removed:
Everything works fine and the result of
curl -i http://localhost:8090/to/do/45
is:The text was updated successfully, but these errors were encountered: