How to get payload from a POST in Play 2.0

前端 未结 4 523
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-07 22:16

I\'m trying to implement a REST API with Play 2.0 (Scala) but I\'m getting stuck in POST method. How do I get the payload from Request object? I haven\'t find any documentation

4条回答
  •  旧巷少年郎
    2021-02-07 22:30

    Here is what I did.

    val map : Map[String,Seq[String]] = request.body
    val seq1 : Seq[String] = map.getOrElse("socket_id", Seq[String]())
    val seq2 : Seq[String] = map.getOrElse("channel_name", Seq[String]())
    val socketId = seq1.head
    val channelName = seq2.head
    

提交回复
热议问题