Last active
September 7, 2018 03:58
-
-
Save moleike/5cae143145501055964fcc1cf681f922 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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