I have a service which has a put endpoint. I want to be able to access the url param as well as the body. How do I achieve this.
This is my endpoint:
put("/:customerNum") { foo: Foo =>
val custNum = ???
}
How do I access customerNum ?
Here how you can extract things related to request:
put("/:customerNum") { request =>
// Get request body
val body = request.getContentString
// Get content type
val contentType = request.contentType
// Get customer number
val customerNum = request.routeParams.get("customerNum")
println(s"Customer number: ${customerNum}. Content Type: $contentType. Body: $body")
render.plain("ok").toFuture
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With