1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | public class HandlerChain { public static void main(String[] args) throws Exception { new HandlerChain().start(); } public void start() throws Exception { RatpackServer.start(server -> server.registry(Registry.single(new ArrayList<String>())) .handlers(chain -> chain.get(ctx -> ctx.insert( addOutput("Hello"), addOutput("World"), ctx3 -> ctx3.render(json(ctx3.get(List.class))) )) ) ); } private Handler addOutput(final String text) { return ctx -> { ctx.get(List.class).add(text); ctx.next(); }; } } |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |