|
| 1 | +// Copyright 2025 The Nomulus Authors. All Rights Reserved. |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | + |
| 15 | +package google.registry.rdap; |
| 16 | + |
| 17 | +import static google.registry.request.Action.Method.GET; |
| 18 | +import static google.registry.request.Action.Method.HEAD; |
| 19 | + |
| 20 | +import google.registry.request.Action; |
| 21 | +import google.registry.request.Response; |
| 22 | +import google.registry.request.auth.Auth; |
| 23 | +import jakarta.inject.Inject; |
| 24 | +import java.io.IOException; |
| 25 | + |
| 26 | +/** |
| 27 | + * RDAP action that serves the empty string, redirecting to the help page. |
| 28 | + * |
| 29 | + * <p>This isn't technically required, but if someone requests the base url it seems nice to give |
| 30 | + * them the help response. |
| 31 | + */ |
| 32 | +@Action( |
| 33 | + service = Action.GaeService.PUBAPI, |
| 34 | + path = "/rdap", |
| 35 | + method = {GET, HEAD}, |
| 36 | + auth = Auth.AUTH_PUBLIC) |
| 37 | +public class RdapEmptyAction implements Runnable { |
| 38 | + |
| 39 | + private final Response response; |
| 40 | + |
| 41 | + @Inject |
| 42 | + public RdapEmptyAction(Response response) { |
| 43 | + this.response = response; |
| 44 | + } |
| 45 | + |
| 46 | + @Override |
| 47 | + public void run() { |
| 48 | + try { |
| 49 | + response.sendRedirect(RdapHelpAction.PATH); |
| 50 | + } catch (IOException e) { |
| 51 | + throw new RuntimeException(e); |
| 52 | + } |
| 53 | + } |
| 54 | +} |
0 commit comments