File tree Expand file tree Collapse file tree 3 files changed +47
-6
lines changed
java/com/maojianwei/lb/routing/rest Expand file tree Collapse file tree 3 files changed +47
-6
lines changed Original file line number Diff line number Diff line change @@ -3,16 +3,19 @@ COMPILE_DEPS = CORE_DEPS + JACKSON + REST + [
3
3
]
4
4
5
5
osgi_jar_with_tests (
6
- karaf_command_packages = ["com.maojianwei.lb.routing" ],
7
6
deps = COMPILE_DEPS ,
8
- )
9
7
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
+ )
10
14
11
15
REQUIRE_APPS = [
12
16
"org.onosproject.proxyarp" ,
13
17
]
14
18
15
-
16
19
onos_app (
17
20
title = "Mao Load-Balance Reactive Forward" ,
18
21
category = "Traffic Steering" ,
Original file line number Diff line number Diff line change 27
27
28
28
import javax .ws .rs .GET ;
29
29
import javax .ws .rs .Path ;
30
+ import javax .ws .rs .Produces ;
31
+ import javax .ws .rs .core .MediaType ;
30
32
import javax .ws .rs .core .Response ;
31
33
import java .util .HashSet ;
32
34
import java .util .Set ;
@@ -56,6 +58,7 @@ public class MaoRestResource extends AbstractWebResource {
56
58
*/
57
59
@ GET
58
60
@ Path ("hello" )
61
+ @ Produces (MediaType .APPLICATION_JSON )
59
62
public Response hello () {
60
63
ObjectNode root = mapper ().createObjectNode ();
61
64
root .put ("Hello" , 1080 )
@@ -64,7 +67,7 @@ public Response hello() {
64
67
ArrayNode array = root .putArray ("RadioStation" );
65
68
array .add ("192.168.1.1" ).add ("127.0.0.1" ).add ("10.3.8.211" );
66
69
67
- return ok (root ).build ();
70
+ return ok (root . toString () ).build ();
68
71
}
69
72
70
73
@@ -78,6 +81,7 @@ public Response hello() {
78
81
*/
79
82
@ GET
80
83
@ Path ("getLinksLoad" )
84
+ @ Produces (MediaType .APPLICATION_JSON )
81
85
public Response getLinksLoad () {
82
86
83
87
Set <String > linksList = new HashSet <>();
@@ -124,7 +128,7 @@ public Response getLinksLoad() {
124
128
capabilities .add (linkNode );
125
129
});
126
130
127
- return ok (root ).build ();
131
+ return ok (root . toString () ).build ();
128
132
}
129
133
130
134
/**
Original file line number Diff line number Diff line change 47
47
<servlet-class >org.glassfish.jersey.servlet.ServletContainer</servlet-class >
48
48
<init-param >
49
49
<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 >
51
51
</init-param >
52
52
<load-on-startup >10</load-on-startup >
53
53
</servlet >
57
57
<url-pattern >/*</url-pattern >
58
58
</servlet-mapping >
59
59
</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
+
You can’t perform that action at this time.
0 commit comments