Created
June 15, 2016 02:10
-
-
Save searler/a28b39327d75596138443ad8cb8cc638 to your computer and use it in GitHub Desktop.
Akka HTTP one way configuration command using case classes
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
def configure[T <: Config](implicit tag: ClassTag[T], convert:FromRequestUnmarshaller[T]) = path("app" / "configure" / tag.runtimeClass.getSimpleName) { | |
post { | |
entity(as[T]) { c => | |
actorRef ! c | |
complete(StatusCodes.OK) | |
} | |
} | |
} | |
trait Config | |
case class Timeout(duration:Duration) extends Config | |
case class MaxLogSize(size:Int) extends Config | |
implicit val timeoutJson = jsonFormat1(Timeout) | |
implicit val maxLogSizeJson = jsonFormat1(MaxLogSize) | |
val route = configure(TimeOut) ~ | |
configure(MaxLogSize) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment