In spray how to unmarshall plain/text?

て烟熏妆下的殇ゞ 提交于 2019-12-10 10:37:16

问题


Can anybody show me an example in spray how to unmarshall POST with content type plain/text ?

How to write the route?

Thanks!


回答1:


This is how the route would look like:

  post {
    entity(as[String]) { str =>
      complete(str)
    }
  }

A sample request would be:

curl -X POST -d 'It works' localhost:8080

which echoes back the POST data.

To get the whole sample app use this official template and add/edit the route.

If you want to understand how it works in detail see this doc and this one.



来源:https://stackoverflow.com/questions/27073173/in-spray-how-to-unmarshall-plain-text

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!