Permalink
Browse files

Initial commit

  • Loading branch information...
plelevier committed Jun 1, 2013
1 parent 3cd98ed commit 7f3d7fc1bf62a1e601dff332bca42d59c5b5ac43
Showing with 96 additions and 4 deletions.
  1. +2 −3 .gitignore
  2. +24 −1 README.md
  3. +40 −0 build.sbt
  4. +3 −0 project/plugins.sbt
  5. +27 −0 src/main/scala/server/BasicServer.scala
View
@@ -8,6 +8,5 @@ lib_managed/
src_managed/
project/boot/
project/plugins/project/
-
-# Scala-IDE specific
-.scala_dependencies
+project/project/
+project/target/
View
@@ -1,4 +1,27 @@
twitter-server-template
=======================
-Simple Project Template for Twitter Server
+Quick-start
+-----------
+
+To generate the project jar :
+
+ $ sbt assembly
+
+Then, to start the BasicServer exemple :
+
+ $ java -jar target/myserver-assembly-0.1.0.jar
+
+To check that the server is running :
+
+ $ curl localhost:8888
+ hello
+
+The admin page is located at :
+
+ http://localhost:8080/admin
+
+
+For more information and documentation about twitter-server :
+
+ http://twitter.github.io/twitter-server/
View
@@ -0,0 +1,40 @@
+import AssemblyKeys._
+
+name := "myserver"
+
+version := "0.1.0"
+
+scalaVersion := "2.9.2"
+
+mainClass := Some("server.BasicServer")
+
+resolvers += "Sonatype Releases Repository" at "http://oss.sonatype.org/content/repositories/releases"
+
+resolvers += "Twitter Maven Repository" at "http://maven.twttr.com"
+
+resolvers += "Maven Repository" at "http://mvnrepository.com/artifact/"
+
+libraryDependencies+= "org.specs2" %% "specs2" % "1.11" % "test"
+
+libraryDependencies += "com.twitter" %% "twitter-server" % "1.0.1"
+
+seq(assemblySettings: _*)
+
+mergeStrategy in assembly <<= (mergeStrategy in assembly) { (old) =>
+ {
+ case _ => MergeStrategy.last // leiningen build files
+ }
+}
+
+excludedFiles in assembly := { (bases: Seq[File]) =>
+ bases flatMap { base =>
+ //Exclude all log4j.properties from other peoples jars
+ ((base * "*").get collect {
+ case f if f.getName.toLowerCase == "log4j.properties" => f
+ }) ++
+ //Exclude the license and manifest from the exploded jars
+ ((base / "META-INF" * "*").get collect {
+ case f if List("manifest.mf", "notice.txt", "license.txt").contains(f.getName.toLowerCase) => f
+ })
+ }
+}
View
@@ -0,0 +1,3 @@
+resolvers += Resolver.url("artifactory", url("http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases"))(Resolver.ivyStylePatterns)
+
+addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.8.3")
@@ -0,0 +1,27 @@
+package server
+
+import com.twitter.finagle.{Http, ListeningServer, NullServer, Service}
+import com.twitter.server.TwitterServer
+import com.twitter.util.{Await, Future}
+import org.jboss.netty.buffer.ChannelBuffers.copiedBuffer
+import org.jboss.netty.handler.codec.http._
+import org.jboss.netty.util.CharsetUtil.UTF_8
+
+object BasicServer extends TwitterServer {
+ val service = new Service[HttpRequest, HttpResponse] {
+ def apply(request: HttpRequest) = {
+ val response =
+ new DefaultHttpResponse(request.getProtocolVersion, HttpResponseStatus.OK)
+ response.setContent(copiedBuffer("hello", UTF_8))
+ Future.value(response)
+ }
+ }
+
+ def main() {
+ val server = Http.serve(":8888", service)
+ onExit {
+ server.close()
+ }
+ Await.ready(server)
+ }
+}

0 comments on commit 7f3d7fc

Please sign in to comment.