Skip to content

Instantly share code, notes, and snippets.

@moleike moleike/routes.scala
Last active Sep 7, 2018

What would you like to do?
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
You can’t perform that action at this time.