001// ***************************************************************************************************************************
002// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.  See the NOTICE file *
003// * distributed with this work for additional information regarding copyright ownership.  The ASF licenses this file        *
004// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance            *
005// * with the License.  You may obtain a copy of the License at                                                              *
006// *                                                                                                                         *
007// *  http://www.apache.org/licenses/LICENSE-2.0                                                                             *
008// *                                                                                                                         *
009// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an  *
010// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the        *
011// * specific language governing permissions and limitations under the License.                                              *
012// ***************************************************************************************************************************
013package org.apache.juneau.rest;
014
015import javax.servlet.http.*;
016
017import org.apache.juneau.dto.swagger.*;
018import org.apache.juneau.html.annotation.*;
019import org.apache.juneau.rest.annotation.*;
020
021/**
022 * Identical to {@link BasicRestServlet} but doesn't extend from {@link HttpServlet}
023 *
024 * <ul class='seealso'>
025 *    <li class='link'>{@doc juneau-rest-server.Instantiation.BasicRest}
026 * </ul>
027 */
028@RestResource(
029   // Allow OPTIONS requests to be simulated using ?method=OPTIONS query parameter.
030   allowedMethodParams="OPTIONS"
031)
032@HtmlDocConfig(
033   // Basic page navigation links.
034   navlinks={
035      "up: request:/..",
036      "options: servlet:/?method=OPTIONS"
037   }
038)
039public abstract class BasicRest implements BasicRestConfig {
040
041   /**
042    * [OPTIONS /*] - Show resource options.
043    *
044    * @param req The HTTP request.
045    * @return A bean containing the contents for the OPTIONS page.
046    */
047   @Override /* BasicRestConfig */
048   public Swagger getOptions(RestRequest req) {
049      // Localized Swagger for this resource is available through the RestRequest object.
050      return req.getSwagger();
051   }
052}