2727
2828import javax .servlet .ServletException ;
2929
30+ import com .alibaba .fastjson .JSON ;
3031import org .unidal .lookup .annotation .Inject ;
3132import org .unidal .web .mvc .PageHandler ;
3233import org .unidal .web .mvc .annotation .InboundActionMeta ;
@@ -141,9 +142,9 @@ public void handleOutbound(Context ctx) throws ServletException, IOException {
141142 model .setContent (routerInfo );
142143 break ;
143144 case JSON :
144- Map <String , String > kvs = buildKvs (report , domain , ip );
145+ Map <String , Map < String , String > > kvs = buildKvs (report , domain , ip );
145146
146- model .setContent (kvs . toString ( ));
147+ model .setContent (JSON . toJSONString ( kvs ));
147148 break ;
148149 case BUILD :
149150 Date period = TimeHelper .getCurrentDay (-1 );
@@ -160,15 +161,17 @@ public void handleOutbound(Context ctx) throws ServletException, IOException {
160161 ctx .getHttpServletResponse ().getWriter ().write (model .getContent ());
161162 }
162163
163- private Map <String , String > buildKvs (RouterConfig report , String domain , String ip ) {
164- Map <String , String > kvs = new HashMap <String , String >();
164+ private Map <String , Map < String , String > > buildKvs (RouterConfig report , String domain , String ip ) {
165+ Map <String , String > map = new HashMap <>();
165166
166- kvs .put ("block" , String .valueOf (m_configManager .shouldBlock (ip )));
167- kvs .put ("routers" , buildRouterInfo (ip , domain , report ));
168- kvs .put ("sample" , String .valueOf (buildSampleInfo (domain )));
169- kvs .put ("startTransactionTypes" , m_filterManager .getAtomicStartTypes ());
170- kvs .put ("matchTransactionTypes" , m_filterManager .getAtomicMatchTypes ());
167+ map .put ("block" , String .valueOf (m_configManager .shouldBlock (ip )));
168+ map .put ("routers" , buildRouterInfo (ip , domain , report ));
169+ map .put ("sample" , String .valueOf (buildSampleInfo (domain )));
170+ map .put ("startTransactionTypes" , m_filterManager .getAtomicStartTypes ());
171+ map .put ("matchTransactionTypes" , m_filterManager .getAtomicMatchTypes ());
171172
172- return kvs ;
173+ Map <String , Map <String , String >> kvConfig = new HashMap <>();
174+ kvConfig .put ("kvs" ,map );
175+ return kvConfig ;
173176 }
174177}
0 commit comments