File tree Expand file tree Collapse file tree 4 files changed +36
-2
lines changed
src/main/java/org/code13k/heets Expand file tree Collapse file tree 4 files changed +36
-2
lines changed Original file line number Diff line number Diff line change 11package org .code13k .heets .model .config .app ;
22
3- public class CacheInfo {
3+ import org .code13k .heets .model .BasicModel ;
4+
5+ public class CacheInfo extends BasicModel {
46 private int defaultExpires ;
57
68 public int getDefaultExpires () {
Original file line number Diff line number Diff line change 11package org .code13k .heets .model .config .app ;
22
3+ import org .code13k .heets .model .BasicModel ;
4+
35import java .util .ArrayList ;
46
5- public class ClusterInfo {
7+ public class ClusterInfo extends BasicModel {
68 private int port ;
79 private ArrayList <String > nodes ;
810
Original file line number Diff line number Diff line change @@ -99,6 +99,15 @@ public void handle(Void event) {
9999 }
100100 });
101101 });
102+ // GET /app/config
103+ router .route ().method (HttpMethod .GET ).path ("/app/config" ).handler (routingContext -> {
104+ routingContext .request ().endHandler (new Handler <Void >() {
105+ @ Override
106+ public void handle (Void event ) {
107+ responseHttpOK (routingContext , mAppAPI .config ());
108+ }
109+ });
110+ });
102111 // GET /app/hello
103112 router .route ().method (HttpMethod .GET ).path ("/app/hello" ).handler (routingContext -> {
104113 routingContext .request ().endHandler (new Handler <Void >() {
Original file line number Diff line number Diff line change 22
33import org .code13k .heets .app .Env ;
44import org .code13k .heets .app .Status ;
5+ import org .code13k .heets .config .AppConfig ;
6+ import org .code13k .heets .model .config .app .CacheInfo ;
7+ import org .code13k .heets .model .config .app .ClusterInfo ;
8+ import org .code13k .heets .model .config .app .PortInfo ;
59import org .slf4j .Logger ;
610import org .slf4j .LoggerFactory ;
711
12+ import java .util .HashMap ;
13+ import java .util .Map ;
14+
815public class AppAPI extends BasicAPI {
916 // Logger
1017 private static final Logger mLogger = LoggerFactory .getLogger (AppAPI .class );
@@ -23,6 +30,20 @@ public String status() {
2330 return toResultJsonString (Status .getInstance ().values ());
2431 }
2532
33+ /**
34+ * config
35+ */
36+ public String config (){
37+ PortInfo portInfo = AppConfig .getInstance ().getPort ();
38+ CacheInfo cacheInfo = AppConfig .getInstance ().getCache ();
39+ ClusterInfo clusterInfo = AppConfig .getInstance ().getCluster ();
40+ Map <String , Object > result = new HashMap <>();
41+ result .put ("port" , portInfo .toMap ());
42+ result .put ("cache" , cacheInfo .toMap ());
43+ result .put ("cluster" , clusterInfo .toMap ());
44+ return toResultJsonString (result );
45+ }
46+
2647 /**
2748 * hello, world
2849 */
You can’t perform that action at this time.
0 commit comments