Skip to content

Instantly share code, notes, and snippets.

@vkostyukov
Created December 23, 2015 19:37
Show Gist options
  • Save vkostyukov/0f0157c1e99410227e94 to your computer and use it in GitHub Desktop.
Save vkostyukov/0f0157c1e99410227e94 to your computer and use it in GitHub Desktop.
Group Endpoints
scala> trait Foo1; trait Foo2
defined trait Foo1
defined trait Foo2
scala> trait Bar1; trait Bar2;
defined trait Bar1
defined trait Bar2
scala> object Foo {
| val endpoints = Endpoint(Ok(new Foo1{})) :+: Endpoint(Ok(new Foo2{}))
| }
defined object Foo
scala> object Bar {
| val endpoints = Endpoint(Ok(new Bar1{})) :+: Endpoint(Ok(new Bar2{}))
| }
defined object Bar
scala> val all = Foo.endpoints :+: Bar.endpoints
all: io.finch.Endpoint[shapeless.:+:[Foo1,shapeless.:+:[Foo2,shapeless.:+:[Bar1,shapeless.:+:[Bar2,shapeless.CNil]]]]] = ((|)|(|))
scala> all.toService
<console>:36: error: You can only convert a router into a Finagle service if the result type of the router is one of the following:
* A Response
* A value of a type with an EncodeResponse instance
* A coproduct made up of some combination of the above
shapeless.:+:[Foo1,shapeless.:+:[Foo2,shapeless.:+:[Bar1,shapeless.:+:[Bar2,shapeless.CNil]]]] does not satisfy the requirement. You may need to provide an EncodeResponse instance for shapeless.:+:[Foo1,shapeless.:+:[Foo2,shapeless.:+:[Bar1,shapeless.:+:[Bar2,shapeless.CNil]]]] (or for some part of
shapeless.:+:[Foo1,shapeless.:+:[Foo2,shapeless.:+:[Bar1,shapeless.:+:[Bar2,shapeless.CNil]]]]).
all.toService
^
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment