Defined separate class for http endpoints
This commit is contained in:
parent
94200d10f2
commit
77bc4c6ccf
|
@ -97,16 +97,14 @@ case class Parameters(level: String, media: String, input_type: String, size: Op
|
||||||
case class Id(id: String)
|
case class Id(id: String)
|
||||||
case class Answer(answer: String, id: String)
|
case class Answer(answer: String, id: String)
|
||||||
|
|
||||||
object LCFramework{
|
class Server(port: Int){
|
||||||
def main(args: scala.Array[String]) {
|
val captcha = new Captcha()
|
||||||
val port = 8888
|
val server = new HTTPServer(port)
|
||||||
val captcha = new Captcha
|
val host = server.getVirtualHost(null)
|
||||||
val server = new HTTPServer(port)
|
|
||||||
val host = server.getVirtualHost(null)
|
|
||||||
|
|
||||||
implicit val formats = DefaultFormats
|
implicit val formats = DefaultFormats
|
||||||
|
|
||||||
host.addContext("/v1/captcha",(req, resp) => {
|
host.addContext("/v1/captcha",(req, resp) => {
|
||||||
val body = req.getJson()
|
val body = req.getJson()
|
||||||
val json = parse(body)
|
val json = parse(body)
|
||||||
val param = json.extract[Parameters]
|
val param = json.extract[Parameters]
|
||||||
|
@ -126,7 +124,7 @@ object LCFramework{
|
||||||
0
|
0
|
||||||
})
|
})
|
||||||
|
|
||||||
host.addContext("/v1/answer",(req, resp) =>{
|
host.addContext("/v1/answer",(req, resp) => {
|
||||||
val body = req.getJson()
|
val body = req.getJson()
|
||||||
val json = parse(body)
|
val json = parse(body)
|
||||||
val answer = json.extract[Answer]
|
val answer = json.extract[Answer]
|
||||||
|
@ -136,6 +134,17 @@ object LCFramework{
|
||||||
resp.send(200,responseContent)
|
resp.send(200,responseContent)
|
||||||
0
|
0
|
||||||
})
|
})
|
||||||
|
|
||||||
|
def start(): Unit = {
|
||||||
|
server.start()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
object LCFramework{
|
||||||
|
def main(args: scala.Array[String]) {
|
||||||
|
|
||||||
|
val server = new Server(8888)
|
||||||
server.start()
|
server.start()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue