问题
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