val t: Thread = new Thread("Server at " + port) {
val dispatch = Map("POST /status/success" -> processSuccess _,
"POST /status/failure" -> processFailure _,
"POST /queryrunstate" -> processRunQuery _,
"GET /comet_request" -> tellThemToShutUp _
)
override def run {
while (!Thread.interrupted()) {
try {
val s = ss.accept
val source = Source.fromInputStream(s.getInputStream)
val rq = source.getLines.next
try {
val f = dispatch.keys.find(rq startsWith _).map(dispatch).getOrElse(ignore _)
f(rq, s, source)
} catch {
case se : SocketException => log(se)
} finally {
s.close
}
} catch {
case ioe: IOException => log(ioe)
case ie: InterruptedException => return
}
}
}
}
def tellThemToShutUp(rq: String, socket: Socket, source: Source) {
Response("oh shut up, this is not the web server you are lookign for", "410 Gone")
}