    001// Licensed under the Apache License, Version 2.0 (the "License");
    002// you may not use this file except in compliance with the License.
    003// You may obtain a copy of the License at
    004//
    005// http://www.apache.org/licenses/LICENSE-2.0
    006//
    007// Unless required by applicable law or agreed to in writing, software
    008// distributed under the License is distributed on an "AS IS" BASIS,
    009// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    010// See the License for the specific language governing permissions and
    011// limitations under the License.
    012
    013package org.apache.tapestry5.http.services;
    014
    015import java.io.IOException;
    016
    017import javax.servlet.http.HttpServletRequest;
    018import javax.servlet.http.HttpServletResponse;
    019
    020import org.apache.tapestry5.http.CorsHandlerResult;
    021
    022/**
    023 * Interface implemented by classes handling CORS (Cross-Origin Resource Sharing) in requests.
    024 * Implementations should be contributed to {@link CorsHttpServletRequestFilter} and
    025 * can use the useful methods from {@link CorsHandlerHelper}.
    026 * @see CorsHandlerHelper
    027 * @see CorsHandlerResult
    028 * @see CorsHttpServletRequestFilter
    029 * @since 5.8.2
    030 */
    031public interface CorsHandler
    032{
    033    /**
    034     * Handles the CORS processing of a request, possibly doing nothing. This method
    035     * cannot return <code>null</code>.
    036     * @return a {@linkplain CorsHandlerResult} object.
    037     */
    038    CorsHandlerResult handle(HttpServletRequest request, HttpServletResponse response) throws IOException;
    039}