Created
March 22, 2015 12:22
-
-
Save magnusart/5dfb824eb66e847d1f84 to your computer and use it in GitHub Desktop.
Shim to get akka-http M4 release to work.
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 akka.http | |
import java.net.InetSocketAddress | |
import akka.http.engine.server.HttpServer.HttpServerPorts | |
import akka.stream.Graph | |
import com.typesafe.config.Config | |
import scala.collection.immutable | |
import scala.concurrent.Future | |
import akka.event.LoggingAdapter | |
import akka.util.ByteString | |
import akka.io.Inet | |
import akka.stream.ActorFlowMaterializer | |
import akka.stream.scaladsl._ | |
import akka.http.engine.client.{ HttpClient, ClientConnectionSettings } | |
import akka.http.engine.server.{ HttpServer, ServerSettings } | |
import akka.http.model.{ ErrorInfo, HttpResponse, HttpRequest } | |
import akka.actor._ | |
class HttpExtShim( config: Config )( implicit system: ActorSystem ) extends HttpExt( config )( system ) { | |
import Http._ | |
override def bindAndstartHandlingWith( handler: Flow[HttpRequest, HttpResponse, _], | |
interface: String, port: Int = 80, backlog: Int = 100, | |
options: immutable.Traversable[Inet.SocketOption] = Nil, | |
settings: Option[ServerSettings] = None, | |
log: LoggingAdapter = system.log )( implicit fm: ActorFlowMaterializer ): Future[ServerBinding] = { | |
bind( interface, port, backlog, options, settings, log ).toMat( Sink.foreach { conn ⇒ | |
conn.flow.join( handler ).run() | |
} )( Keep.left ).run() | |
} | |
} | |
object HttpShim extends ExtensionId[HttpExtShim] with ExtensionIdProvider { | |
import Http._ | |
def apply()( implicit system: ActorSystem ): HttpExtShim = super.apply( system ) | |
def lookup() = HttpShim | |
def createExtension( system: ExtendedActorSystem ): HttpExtShim = | |
new HttpExtShim( system.settings.config getConfig "akka.http" )( system ) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment