Skip to content

Instantly share code, notes, and snippets.

@chadselph
Last active November 8, 2016 02:28
Show Gist options
  • Save chadselph/baa3204fed9977b96bd977dd85f6747e to your computer and use it in GitHub Desktop.
Save chadselph/baa3204fed9977b96bd977dd85f6747e to your computer and use it in GitHub Desktop.
trying to pass along the type of a PathMatcher to a abstract Route member
package gist.chadselph
import akka.http.scaladsl.server.PathMatcher
import akka.http.scaladsl.server._
import akka.http.scaladsl.server.Directives._
import akka.http.scaladsl.server.util.ApplyConverter
/**
* Created by chad on 11/4/16.
*/
abstract class ApiFormats[PathType](val basePath: PathMatcher[PathType],
// include as parameter, because implicits are private, so
// their type members can't be exported
val hac: ApplyConverter[PathType]) {
def create: hac.In
final val createRoute: Route = {
val matcher = post & path(basePath)
matcher.tapply(hac(create))
}
}
object Foo {
val v1Formats = new ApiFormats("v1" / Segment / "things" / Segment,
implicitly[ApplyConverter[(String, String)]]) {
/*
Information:scalac: => (String, String) => akka.http.scaladsl.server.Route <: => this.hac.In?
Information:scalac: false
Error:(31, 18) overriding method create in class ApiFormats of type => this.hac.In;
value create has incompatible type
*/
override val create: ((String, String) => Route) = { (f, s) =>
complete(f)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment