Skip to content

Instantly share code, notes, and snippets.

@moleike
Last active September 7, 2018 03:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moleike/5cae143145501055964fcc1cf681f922 to your computer and use it in GitHub Desktop.
Save moleike/5cae143145501055964fcc1cf681f922 to your computer and use it in GitHub Desktop.
import io.finch._
import io.finch.syntax._
import shapeless._
import scala.language.existentials
trait Route {
private object base extends Endpoint[HNil] {
def apply(input: Input): Endpoint.Result[HNil] = EndpointResult.NotMatched
}
def endpoints: Endpoint[_] = base
}
trait Foo extends Route {
override def endpoints = get("foo") :+: super.endpoints
}
trait Bar extends Route {
override def endpoints = get("bar") :+: super.endpoints
}
object api extends Foo with Bar
api.endpoints(Input.get("/")) // NotMatched
api.endpoints(Input.get("/foo")) // Matched
api.endpoints(Input.get("/bar")) // Matched
//
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment