Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Created by Edmund on 2015-03-21.
- */
- import org.scalatra._
- import scalate.ScalateSupport
- import scala.collection.mutable
- import scala.language.postfixOps
- // JSON-related libraries
- import org.json4s.{DefaultFormats, Formats}
- // JSON handling support from Scalatra
- import org.scalatra.json._
- class MyScalatraServlet extends ScalatraServlet with JacksonJsonSupport {
- protected implicit val jsonFormats: Formats = DefaultFormats
- before() {
- contentType = formats("json")
- }
- case class Datas(name: String)
- val datast = mutable.ListBuffer(
- Datas("Blank")
- )
- get("/") {
- datast
- }
- post("/") {
- val newDatas = parsedBody.extractOpt[Datas]
- newDatas foreach {datast +=}
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement