You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importzio.*importzio.http.*importzio.http.codec.*importzio.http.endpoint.AuthType.Noneimportzio.http.endpoint.EndpointobjectZIOHttpTestextendsZIOAppDefault:privateobjectendpoints:valhelloEndpoint:Endpoint[Unit, Unit, ZNothing, String, None] =Endpoint(Method.GET/"hello"/"world")
.out[String]
valgreetEndpoint:Endpoint[Unit, Unit, ZNothing, String, None] =Endpoint(Method.GET/"greet")
.out[String]
privatevalhelloRoute:Routes[Any, Nothing] =
endpoints
.helloEndpoint
.implement(_ =>ZIO.succeed("some business logic"))
.toRoutes
privatevalgreetRoute:Routes[Any, Nothing] =
endpoints
.greetEndpoint
.implement(_ =>ZIO.succeed("some greeting business logic"))
.toRoutes
privatevalallRoutesCombined= helloRoute ++ greetRoute
/** need to prepend 'test-services' to all my routes */overridevalrun:ZIO[Any, Throwable, Nothing] =Server.serve(allRoutesCombined.nest("test-services")).provide(Server.defaultWithPort(9000))
The nest function does not work and returns a Malformed error when I call localhost:9000/test-services/hello/world.
I tried reading some documentation related to Routes and Endpoint however I cannot find a way to prepend test-servicesPath to my existing Route or Endpoint.
My APIs are:
hello/world
greet
and before submitting it to Server I want my routes to be prepended with test-services, any suggestions as to what I am doing wrong. Ofcourse, I can add test-services explicitly to all my Endpoints but this makes it restrictive since every endpoint need to have the same test-services path.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
The
nestfunction does not work and returns aMalformederror when I calllocalhost:9000/test-services/hello/world.I tried reading some documentation related to
RoutesandEndpointhowever I cannot find a way to prependtest-servicesPathto my existingRouteorEndpoint.My APIs are:
hello/world
greet
and before submitting it to
ServerI want my routes to be prepended withtest-services, any suggestions as to what I am doing wrong. Ofcourse, I can addtest-servicesexplicitly to all myEndpointsbut this makes it restrictive since every endpoint need to have the sametest-servicespath.Using Scala 3.3.4 with zio-http 3.0.1
Beta Was this translation helpful? Give feedback.
All reactions