| <!-- |
| /*************************************************************************************************************************** |
| * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file |
| * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file |
| * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance |
| * with the License. You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an |
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the |
| * specific language governing permissions and limitations under the License. |
| ***************************************************************************************************************************/ |
| --> |
| |
| RequestBody |
| |
| <p> |
| The {@link oajr.RequestBody} object is the API for accessing the body of an HTTP request. |
| It can be accessed by passing it as a parameter on your REST Java method: |
| </p> |
| <p class='bpcode w800'> |
| <ja>@RestMethod</ja>(...) |
| <jk>public</jk> Object myMethod(RequestBody body) {...} |
| </p> |
| <h5 class='figure'>Example:</h5> |
| <p class='bpcode w800'> |
| <ja>@RestMethod</ja>(...) |
| <jk>public void</jk> doPost(RequestBody body) { |
| <jc>// Convert body to a linked list of Person objects.</jc> |
| List<Person> l = body.asType(LinkedList.<jk>class</jk>, Person.<jk>class</jk>); |
| ... |
| } |
| </p> |
| <p> |
| Some important methods on this class are: |
| </p> |
| <ul class='javatree'> |
| <li class='jc'>{@link oajr.RequestBody} |
| <ul> |
| <li class='jm'>{@link oajr.RequestBody#getReader() getReader()} - Get body as a Reader. |
| <li class='jm'>{@link oajr.RequestBody#getInputStream() getInputStream()} - Get body as an InputStream. |
| <li class='jm'>{@link oajr.RequestBody#asType(Class) asType(Class)} - Get body converted to a POJO. |
| <li class='jm'>{@link oajr.RequestBody#asType(Type,Type...) asType(Type,Type...)} - Get body converted to a map or collection of POJOs. |
| <li class='jm'>{@link oajr.RequestBody#asString() asString()} - Get body as a simple string. |
| <li class='jm'>{@link oajr.RequestBody#asHex() asHex()} - Get body as a hex-encoded string. |
| <li class='jm'>{@link oajr.RequestBody#asSpacedHex() asSpacedHex()} - Get body as spaced-hex-encoded string. |
| </ul> |
| </ul> |
| |
| <ul class='seealso'> |
| <li class='ja'>{@link oaj.http.annotation.Body} |
| </ul> |