Skip to content

Commit 9bc504b

Browse files
committed
Re-enable Rest API, dropdown menu of http://<controller-ip>:8181/onos/v1/docs
1 parent 0683c97 commit 9bc504b

File tree

3 files changed

+47
-6
lines changed

3 files changed

+47
-6
lines changed

BUILD

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,19 @@ COMPILE_DEPS = CORE_DEPS + JACKSON + REST + [
33
]
44

55
osgi_jar_with_tests (
6-
karaf_command_packages = ["com.maojianwei.lb.routing"],
76
deps = COMPILE_DEPS,
8-
)
97

8+
api_package = "com.maojianwei.lb.routing",
9+
api_description = "BigMao Radio Station REST API v1.0, for Load-Balance Routing",
10+
api_title = "BigMao Radio Station REST API v1.0",
11+
api_version = "/onos/v1/Mao",
12+
web_context = "/onos/Mao",
13+
)
1014

1115
REQUIRE_APPS = [
1216
"org.onosproject.proxyarp",
1317
]
1418

15-
1619
onos_app (
1720
title = "Mao Load-Balance Reactive Forward",
1821
category = "Traffic Steering",

src/main/java/com/maojianwei/lb/routing/rest/MaoRestResource.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727

2828
import javax.ws.rs.GET;
2929
import javax.ws.rs.Path;
30+
import javax.ws.rs.Produces;
31+
import javax.ws.rs.core.MediaType;
3032
import javax.ws.rs.core.Response;
3133
import java.util.HashSet;
3234
import java.util.Set;
@@ -56,6 +58,7 @@ public class MaoRestResource extends AbstractWebResource {
5658
*/
5759
@GET
5860
@Path("hello")
61+
@Produces(MediaType.APPLICATION_JSON)
5962
public Response hello() {
6063
ObjectNode root = mapper().createObjectNode();
6164
root.put("Hello", 1080)
@@ -64,7 +67,7 @@ public Response hello() {
6467
ArrayNode array = root.putArray("RadioStation");
6568
array.add("192.168.1.1").add("127.0.0.1").add("10.3.8.211");
6669

67-
return ok(root).build();
70+
return ok(root.toString()).build();
6871
}
6972

7073

@@ -78,6 +81,7 @@ public Response hello() {
7881
*/
7982
@GET
8083
@Path("getLinksLoad")
84+
@Produces(MediaType.APPLICATION_JSON)
8185
public Response getLinksLoad() {
8286

8387
Set<String> linksList = new HashSet<>();
@@ -124,7 +128,7 @@ public Response getLinksLoad() {
124128
capabilities.add(linkNode);
125129
});
126130

127-
return ok(root).build();
131+
return ok(root.toString()).build();
128132
}
129133

130134
/**

src/main/webapp/WEB-INF/web.xml

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
4848
<init-param>
4949
<param-name>jersey.config.server.provider.classnames</param-name>
50-
<param-value>com.maojianwei.lb.routing.rest.MaoRestApplication</param-value>
50+
<param-value>com.maojianwei.lb.routing.rest.MaoRestResource</param-value>
5151
</init-param>
5252
<load-on-startup>10</load-on-startup>
5353
</servlet>
@@ -57,3 +57,37 @@
5757
<url-pattern>/*</url-pattern>
5858
</servlet-mapping>
5959
</web-app>
60+
61+
62+
63+
64+
65+
66+
67+
68+
69+
70+
71+
72+
73+
74+
75+
76+
77+
78+
79+
80+
81+
82+
83+
84+
85+
86+
87+
88+
89+
90+
91+
92+
93+

0 commit comments

Comments
 (0)