Last active
November 8, 2016 02:28
-
-
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
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
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