Created
August 5, 2012 20:41
-
-
Save icambridge/3267065 to your computer and use it in GitHub Desktop.
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
import com.typesafe.startscript.StartScriptPlugin | |
seq(StartScriptPlugin.startScriptForClassesSettings: _*) | |
name := "hello" | |
version := "1.0" | |
scalaVersion := "2.9.1" | |
resolvers += "twitter-repo" at "http://maven.twttr.com" | |
libraryDependencies ++= Seq("com.twitter" % "finagle-core" % "1.9.0", | |
"com.twitter" % "finagle-http" % "1.9.0") |
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
import com.typesafe.startscript.StartScriptPlugin | |
seq(StartScriptPlugin.startScriptForClassesSettings: _*) | |
name := "hello" | |
version := "1.0" | |
scalaVersion := "2.9.1" | |
resolvers += "twitter-repo" at "http://maven.twttr.com" | |
libraryDependencies ++= Seq("com.twitter" % "finagle-core" % "1.9.0", | |
"com.twitter" % "finagle-http" % "1.9.0") |
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
resolvers += Classpaths.typesafeResolver | |
addSbtPlugin("com.typesafe.startscript" % "xsbt-start-script-plugin" % "0.3.0") |
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
import org.jboss.netty.handler.codec.http.{HttpRequest, HttpResponse} | |
import com.twitter.finagle.builder.ServerBuilder | |
import com.twitter.finagle.http.{Http, Response} | |
import com.twitter.finagle.Service | |
import com.twitter.util.Future | |
import java.net.InetSocketAddress | |
import util.Properties | |
object Web { | |
def main(args: Array[String]) { | |
val port = Properties.envOrElse("PORT", "8080").toInt | |
println("Starting on port:"+port) | |
ServerBuilder() | |
.codec(Http()) | |
.name("hello-server") | |
.bindTo(new InetSocketAddress(port)) | |
.build(new Hello) | |
} | |
} | |
class Hello extends Service[HttpRequest, HttpResponse] { | |
def apply(req: HttpRequest): Future[HttpResponse] = { | |
val response = Response() | |
response.setStatusCode(200) | |
val uri = req.getUri | |
val headers = req.getHeaders | |
var output = "uri : " + uri + "<br />" | |
//headers asScala foreach { header => | |
// output += "headers: " + header + "<br />" | |
//} | |
response.setContentString(output) | |
Future(response) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment