Documentation for App Mapping Capabilities

If I create an app, enable OAuth and setup the following mapping...

mappings {
  path("/post") {
    action: [
      POST: "postHandler"
    ]
  }
}

I'm noticing that depending on the payload of the post it may or may not be passed onto the "request" object and in some cases the handler is not called. Is there somebody that can point me to an example or documentation that tells me more about these capabilities?

For example, if I post short strings, JSON, etc. then that value almost always appears in request.body. If it is longer then it only appears in request.body once which to me means that request.body is a stream, maybe the very stream from the response. If I post binary data then the handler is never called. There are several other situations when it's not called. What are the rules here? What are we allowed to post? What if I wanted to post binary data, a file, etc. Can I do that and if so, how? Doing it the same way small strings and JSON is posted just doesn't call the handler.

M'kay. I think I might have figured out a few things... It was called. However, the size of the file must have been big enough that when I printed it to in live logging something broke. If I reload past logs it's there. Also, it is very particular about content type.

If you put in a content type it tries to parse it to that type of content (like the other outbound methods we have so I guess this makes sense). If JSON isn't valid JSON and you supply 'application/json' as the content type your method may not get called. At least I seemed to see this with a simple example... With this as the body my method wasn't called.

{ name: "John", location: "Boston" }

But with this it was:

{ "name": "John", "location": "Boston" }

And the first isn't really valid JSON so I guess that's okay. Groovy has made me so lazy that it sort of carried over into other languages/styles that aren't as forgiving.

1 Like

I had this happen recently for something unrelated. I was doing an httpPost posting about 100KB of data and I thought it wasn't calling my method. It turns out my log.debug was the culprit. It didn't like me spitting out such a large debug line. Once I removed it things worked.