Can anybody show me an example in spray how to unmarshall POST with content type plain/text ?
How to write the route?
Thanks!
Can anybody show me an example in spray how to unmarshall POST with content type plain/text ?
How to write the route?
Thanks!
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.
SprayJsonSupport._
etc. Optimally, you just import it exactly in the scopes where you need it and not globally for the file which contains all of your routes. –
Adjutant © 2022 - 2024 — McMap. All rights reserved.