More work on IO reST docs
This commit is contained in:
parent
6265f68ba9
commit
2ac8a25b72
2 changed files with 92 additions and 48 deletions
|
|
@ -3,10 +3,13 @@
|
|||
*/
|
||||
package akka.docs.io
|
||||
|
||||
//#imports
|
||||
import akka.actor._
|
||||
import akka.util.{ ByteString, ByteStringBuilder }
|
||||
import java.net.InetSocketAddress
|
||||
//#imports
|
||||
|
||||
//#actor
|
||||
class HttpServer(port: Int) extends Actor {
|
||||
|
||||
val state = IO.IterateeRef.Map.async[IO.Handle]()(context.dispatcher)
|
||||
|
|
@ -31,7 +34,9 @@ class HttpServer(port: Int) extends Actor {
|
|||
}
|
||||
|
||||
}
|
||||
//#actor
|
||||
|
||||
//#actor-companion
|
||||
object HttpServer {
|
||||
import HttpIteratees._
|
||||
|
||||
|
|
@ -54,6 +59,7 @@ object HttpServer {
|
|||
}
|
||||
|
||||
}
|
||||
//#actor-companion
|
||||
|
||||
//#request-class
|
||||
case class Request(meth: String, path: List[String], query: Option[String], httpver: String, headers: List[Header], body: Option[ByteString])
|
||||
|
|
@ -209,8 +215,10 @@ object OKResponse {
|
|||
case class OKResponse(body: ByteString, keepAlive: Boolean)
|
||||
//#ok-response
|
||||
|
||||
//#main
|
||||
object Main extends App {
|
||||
val port = Option(System.getenv("PORT")) map (_.toInt) getOrElse 8080
|
||||
val system = ActorSystem()
|
||||
val server = system.actorOf(Props(new HttpServer(port)))
|
||||
}
|
||||
//#main
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue