File tree Expand file tree Collapse file tree 2 files changed +26
-7
lines changed
Expand file tree Collapse file tree 2 files changed +26
-7
lines changed Original file line number Diff line number Diff line change @@ -16,15 +16,34 @@ package org.httprpc.test
1616
1717import org.httprpc.RequestMethod
1818import org.httprpc.WebService
19+ import java.net.InetAddress
1920import javax.servlet.annotation.WebServlet
2021
2122/* *
22- * Kotlin example service.
23+ * System info service.
2324 */
24- @WebServlet(urlPatterns = [" /kotlin /*" ], loadOnStartup = 1 )
25- class KotlinService : WebService () {
25+ @WebServlet(urlPatterns = [" /system-info /*" ], loadOnStartup = 1 )
26+ class SystemInfoService : WebService () {
2627 @RequestMethod(" GET" )
27- fun sayHello (): String {
28- return " Hello from Kotlin"
28+ fun getSystemInfo (): SystemInfo {
29+ val localHost = InetAddress .getLocalHost()
30+ val runtime = Runtime .getRuntime()
31+
32+ return SystemInfo (
33+ localHost.hostName,
34+ localHost.hostAddress,
35+ runtime.availableProcessors(),
36+ runtime.freeMemory(),
37+ runtime.totalMemory()
38+ )
2939 }
40+ }
41+
42+ class SystemInfo (
43+ val hostName : String ,
44+ val hostAddress : String ,
45+ val availableProcessors : Int ,
46+ val freeMemory : Long ,
47+ val totalMemory : Long
48+ ) {
3049}
Original file line number Diff line number Diff line change 104104
105105<hr />
106106
107- <a href =" ${ pageContext. request. contextPath } /kotlin ?api" >Kotlin (API)</a ><br />
107+ <a href =" ${ pageContext. request. contextPath } /system-info ?api" >System Info (API)</a ><br />
108108<br />
109- <a href =" ${ pageContext. request. contextPath } /kotlin " >Kotlin </a ><br />
109+ <a href =" ${ pageContext. request. contextPath } /system-info " >System Info </a ><br />
110110
111111<hr />
112112
You can’t perform that action at this time.
0 commit comments