Commit 8294b136 authored by Tom Käsler's avatar Tom Käsler

add new route to create question for session regardless of given sessionid

parent 98ccc651
......@@ -64,5 +64,28 @@ trait QuestionApi {
}
}
}
} ~
pathPrefix(ApiRoutes.getRoute("session")) {
pathPrefix(IntNumber) { sessionId =>
pathPrefix(ApiRoutes.getRoute("question")) {
pathEndOrSingleSlash {
get {
parameters("variant".?) { variant =>
variant match {
case Some(v) => complete(QuestionService.findQuestionsBySessionIdAndVariant(sessionId, v)
.map(questionAdapter.toResources(_)))
case None => complete {QuestionService.findAllBySessionId(sessionId)
.map(questionAdapter.toResources(_))}
}
}
} ~
post {
entity(as[Question]) { question =>
complete (QuestionService.create(question.copy(sessionId = sessionId)).map(_.toJson))
}
}
}
}
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment