scala - How to embed Play 2.6 using Akka HTTP Server? -


play 2.5 used netty default , allowed easy embedding. https://www.playframework.com/documentation/2.5.x/scalaembeddingplay

how done akka http server, default server backend?

the page https://www.playframework.com/documentation/2.6.x/scalaembeddingplay missing.

the documentation split in 2 pages:

  1. for akka http server: https://www.playframework.com/documentation/2.6.1/scalaembeddingplayakkahttp
  2. for netty server: https://www.playframework.com/documentation/2.6.1/scalaembeddingplaynetty

you should use akkahttpservercomponents avoid deprecated apis:

import play.api.{ builtincomponents, nohttpfilterscomponents } import play.api.mvc._ import play.api.routing.router import play.api.routing.sird._ import play.core.server.akkahttpservercomponents  val server = new akkahttpservercomponents builtincomponents nohttpfilterscomponents {    // avoid using deprecated action builder while   // keeping `action` idiom.   private val action = defaultactionbuilder    override def router: router = router.from {     case get(p"") => action {       results.ok("hello, world")     }   }   }.server 

Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -