001/* 002 * The contents of this file are subject to the terms of the Common Development and 003 * Distribution License (the License). You may not use this file except in compliance with the 004 * License. 005 * 006 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the 007 * specific language governing permission and limitations under the License. 008 * 009 * When distributing Covered Software, include this CDDL Header Notice in each file and include 010 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL 011 * Header, with the fields enclosed by brackets [] replaced by your own identifying 012 * information: "Portions Copyright [year] [name of copyright owner]". 013 * 014 * Copyright 2015 ForgeRock AS. 015 */ 016 017package org.forgerock.openig.handler; 018 019import static org.forgerock.http.protocol.Response.newResponsePromise; 020 021import org.forgerock.http.Handler; 022import org.forgerock.http.protocol.Request; 023import org.forgerock.http.protocol.Response; 024import org.forgerock.http.protocol.Status; 025import org.forgerock.services.context.Context; 026import org.forgerock.util.promise.NeverThrowsException; 027import org.forgerock.util.promise.Promise; 028 029/** 030 * Provides commonly used handler implementations. 031 */ 032public final class Handlers { 033 034 /** 035 * Utility class. 036 */ 037 private Handlers() { } 038 039 /** 040 * A default {@link Handler} implementation that returns an empty ({@literal 204 No Content}) {@link Response}. 041 */ 042 public static final Handler NO_CONTENT = new Handler() { 043 @Override 044 public Promise<Response, NeverThrowsException> handle(final Context context, final Request request) { 045 return newResponsePromise(new Response(Status.NO_CONTENT)); 046 } 047 }; 048 049}