Build Httpserver with Akka

Source: Internet
Author: User

AKKa version of Httpserver

Official Document: http://akka.io/docs/?_ga=1.258204936.386978128.1439703494

Add the following dependencies in Maven:

    <dependencies>        <dependency>            <groupId>com.typesafe.akka</groupId>            < artifactid>akka-stream-experimental_2.11</artifactid>            <version>1.0</version>        < /dependency>        <dependency>            <groupId>com.typesafe.akka</groupId>            <artifactid >akka-http-core-experimental_2.11</artifactId>            <version>1.0</version>        </ dependency>        <dependency>            <groupId>com.typesafe.akka</groupId>            < artifactid>akka-http-experimental_2.11</artifactid>            <version>1.0</version>        < /dependency>    

Build httpserver using the following code:

Import Akka.actor.ActorSystemimport Akka.stream.ActorMaterializerimport Akka.stream.scaladsl.Sinkimport Akka.http.scaladsl.Httpimport Akka.http.scaladsl.model.httpmethods._import Akka.http.scaladsl.model._import Scala.concurrent.Futureobject Httpserver extends App {implicit val system = Actorsystem () implicit val Materializer = A Ctormaterializer () Val serversource = Http (). Bind (interface = "localhost", port = 8080) Val requesthandler:httprequest = = HttpResponse = {Case HttpRequest (GET, Uri.path ("/"), _, _, _) = = HttpResponse (entity = httpentity (Mediat Ypes. ' text/html ', "

Build Httpserver with Akka

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.