2 * Copyright (c) 2020 ZTE Corp. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.restconf.nb.rfc8040.rests.services.impl;
10 import static java.util.Objects.requireNonNull;
12 import javax.ws.rs.Path;
13 import javax.ws.rs.core.Response;
14 import javax.ws.rs.core.Response.Status;
15 import org.opendaylight.restconf.nb.rfc8040.rests.services.api.RootResourceDiscoveryService;
18 public final class RootResourceDiscoveryServiceImpl implements RootResourceDiscoveryService {
19 private final String restconfRoot;
21 public RootResourceDiscoveryServiceImpl(final String restconfRoot) {
22 this.restconfRoot = requireNonNull(restconfRoot);
26 public Response readXrdData() {
27 return Response.status(Status.OK)
28 .entity("<?xml version='1.0' encoding='UTF-8'?>\n"
29 + "<XRD xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0'>\n"
30 + " <Link rel='restconf' href='/" + restconfRoot + "'/>\n"
36 public Response readJsonData() {
37 return Response.status(Status.OK)
41 + " \"rel\" : \"restconf\",\n"
42 + " \"href\" : \"/" + restconfRoot + "\"\n"