001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.juneau.rest.server.ops; 018 019import java.util.*; 020 021import org.apache.juneau.http.*; 022import org.apache.juneau.http.response.*; 023import org.apache.juneau.rest.server.*; 024import org.apache.juneau.rest.server.servlet.*; 025import org.apache.juneau.rest.server.staticfile.*; 026 027/** 028 * Mixin providing the residual {@code [GET /htdocs/*]} static-file endpoint. 029 * 030 * <p> 031 * Single-responsibility op-mixin carved out of the former {@code BasicRestOperations} interface. Delegates the 032 * requested path to {@link StaticFilesMixin#resolveStaticFile(RestRequest,String,Locale)} — the same 033 * resolution chokepoint used by the newer {@link StaticFilesMixin}'s configurable-mount handlers — so 034 * there is a single implementation of the static-file lookup logic even though this mixin keeps its own fixed, 035 * {@code GET}-only {@code /htdocs/*} mount for backward compatibility. 036 * 037 * <p> 038 * The greedy {@code /htdocs/*} blob handler is not API-meaningful and is excluded from the published 039 * Swagger/OpenAPI specification via {@link OpSwagger#ignore() @OpSwagger(ignore=true)}. 040 * 041 * <h5 class='section'>See Also:</h5><ul> 042 * <li class='jc'>{@link StaticFilesMixin} 043 * </ul> 044 * 045 * @since 10.0.0 046 */ 047@Rest 048public class HtdocMixin extends RestMixin { 049 050 /** 051 * [GET /htdocs/*] - Retrieve static file. 052 * 053 * @param req The HTTP request. 054 * @param path The path to retrieve. 055 * @param locale The locale of the HTTP request. 056 * @return An HTTP resource representing the static file. 057 * @throws NotFound If no resource matches the requested path. 058 */ 059 @RestGet( 060 path="/htdocs/*", 061 summary="Static files", 062 description="Static file retrieval.", 063 swagger=@OpSwagger(ignore=true) 064 ) 065 public HttpResource getHtdoc(RestRequest req, @Path("/*") String path, Locale locale) throws NotFound { 066 return StaticFilesMixin.resolveStaticFile(req, path, locale); 067 } 068}