| <!-- |
| /*************************************************************************************************************************** |
| * 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. |
| ***************************************************************************************************************************/ |
| --> |
| |
| Default Headers |
| |
| <p> |
| The following annotations are provided for specifying default header values for requests and responses: |
| </p> |
| <ul class='javatree'> |
| <li class='ja'> |
| {@link oajr.annotation.Rest#reqHeaders() Rest(reqHeaders)} |
| <br>Defines default headers on request when the client doesn't specify them. |
| <li class='ja'> |
| {@link oajr.annotation.Rest#resHeaders() Rest(resHeaders)} |
| <br>Appends the specified headers if they weren't already set programmatically. |
| </ul> |
| |
| <h5 class='figure'>Example:</h5> |
| <p class='bpcode w800'> |
| <jc>// Servlet with default headers</jc> |
| <ja>@Rest</ja>( |
| |
| <jc>// Assume "text/json" Accept value when Accept not specified</jc> |
| reqHeaders={<js>"Accept: text/json"</js>}, |
| |
| <jc>// Add a version header attribute to all responses</jc> |
| resHeaders={<js>"X-Version: 1.0"</js>} |
| ) |
| <jk>public</jk> MyRestServlet <jk>extends</jk> BasicRestServlet { |
| ... |
| } |
| </p> |
| <p> |
| Default headers can also be specified programmatically by overriding the following methods: |
| </p> |
| <ul class='javatree'> |
| <li class='jac'> |
| {@link oajr.RestContextBuilder} |
| <ul> |
| <li class='jm'> |
| {@link oajr.RestContextBuilder#reqHeaders(String[])} |
| <li class='jm'> |
| {@link oajr.RestContextBuilder#resHeaders(String[])} |
| </ul> |
| </li> |
| </ul> |