packagecom.sam.routes/**
* Created by SAM on 2016/3/29.
*/traitRestInterfaceextendsPostsOperations{valroutes={postsRoutes}}

AkkaHttpMicroservice.scala

packagecom.sam.serverimportakka.actor.ActorSystemimportakka.event.Loggingimportakka.http.scaladsl.Httpimportakka.stream.ActorMaterializerimportcom.sam.routes.RestInterfaceimportcom.typesafe.config.ConfigFactory/**
* Created by SAM on 2016/3/29.
*/objectAkkaHttpMicroserviceextendsAppwithRestInterface{overrideimplicitvalsystem=ActorSystem()overrideimplicitvalexecutor=system.dispatcheroverrideimplicitvalmaterializer=ActorMaterializer()overridevalconfig=ConfigFactory.load()overridevallogger=Logging(system,getClass)valport=config.getInt("http.port")valinterface=config.getString("http.interface")valbinding=Http().bindAndHandle(routes,interface,port)logger.info(s"Bound to port $port on interface $interface")bindingonFailure{caseex:Exception⇒logger.error(s"Failedtobindto$interface:$port!",ex)}sys.addShutdownHook(system.terminate())}