sup icon indicating copy to clipboard operation
sup copied to clipboard

String to Uri

Open benkio opened this issue 4 years ago • 3 comments

I'm trying this method https://github.com/kubukoz/sup/blob/9887f19c9873880252f96b86cd9d88de39eeca2e/modules/http4s/src/main/scala/sup/modules/http4s.scala#L19-L22

and I found that, overriding the path field, I can't put the health check route endpoint far from the root of the service, eg:

  • "healthCheckFoo": resulting in localhost/myHealthcheck works, 200
  • "bar/healthCheckFoo": doesn't work, 404

I think the parameter type should change, from String to Uri

benkio avatar Nov 03 '21 14:11 benkio

hmm Uri has the problem that it could be absolute. While I agree the current state is problematic, I'm not convinced that's the best solution. Maybe a list of segments instead?

A workaround at the moment would be to wrap these routes in Router to add extra segments. e.g. Router("bar" -> healthCheckRoutes(..., "healthCheckFoo")).

@rossabaker what do you think about using Uri in this case?

kubukoz avatar Nov 03 '21 14:11 kubukoz

A Uri.Path is basically just a Vector of segments that may or may not be absolute. Even if it is absolute, you can ignore that and append it to some other prefix. And you won't have schemes, authorities, etc. to discard.

rossabaker avatar Nov 03 '21 19:11 rossabaker

oh, Uri.Path sounds great then. Thanks!

I'd add that, but keep the existing signature as well.

kubukoz avatar Nov 03 '21 22:11 kubukoz