| <!-- |
| /*************************************************************************************************************************** |
| * 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. |
| ***************************************************************************************************************************/ |
| --> |
| |
| ReaderResource |
| |
| <p> |
| The {@link oaj.http.ReaderResource} class is a convenience object for defining thread-safe |
| reusable character-based responses. |
| In essence, it's a container for character data with optional response headers and support for |
| resolving SVL variables. |
| </p> |
| |
| <p> |
| The class is annotated with {@link oaj.http.annotation.Response @Response} |
| which allows it to be returned as responses by REST methods. |
| </p> |
| <h5 class='figure'>Example:</h5> |
| <p class='bpcode w800'> |
| <ja>@RestMethod</ja> |
| <jk>public</jk> Object sayHello(RestRequest req) { |
| |
| <jc>// Return a reader resource loaded from a file with support for request-time SVL variables.</jc> |
| <jk>return</jk> ReaderResource.<jsm>create</jsm>() |
| .contents(<jk>new</jk> File(<js>"helloWorld.txt"</js>)) |
| .varResolver(req.getVarResolver()) |
| .header(<js>"Cache-Control"</js>, <js>"no-cache"</js>) |
| .mediaType(<jsf>TEXT_PLAIN</jsf>) |
| .build(); |
| } |
| </p> |