How to access Scalatra HTTP POST content (data) in post method

If you have a Scalatra POST method like this:

post("/foo") {
  // do stuff here

you can access the data that's sent to your POST function by using the implicit request object, like this:

val content = request.body

Then you can operate on that content as desired.

Add new comment

The content of this field is kept private and will not be shown publicly.

Anonymous format

  • Allowed HTML tags: <em> <strong> <cite> <code> <ul type> <ol start type> <li> <pre>
  • Lines and paragraphs break automatically.