package pl.setblack.javafun.ratschool;

import ratpack.server.RatpackServer;

public class MyServer {
    public static void main(String[] args) throws Exception {
        RatpackServer.start(server ->
                server
                        .serverConfig(cfg->cfg.development(true))
                .handlers(chain -> chain
                        .prefix("add", add ->add
                        .get(":n",
                                ctx -> {
                                        final long n = Long.parseLong(ctx.getPathTokens().get("n"));
                                        ctx.render(String.valueOf(n+1));
                                })
                        )
                )
        );
    }
}

@@ -75,31 +75,142 @@
 r;%0A%0A
-public class MyServer %7B
+import java.util.concurrent.atomic.AtomicLong;%0A%0Apublic class MyServer %7B%0A%0A    private static final AtomicLong cnt = new AtomicLong(0);%0A
 %0A   
@@ -509,16 +509,20 @@
         
+    
 .get(%22:n
@@ -790,32 +790,265 @@
                 
+    )%0A                        .prefix(%22counter%22, counter -%3E%0A                                counter.post(%22inc%22, ctx -%3E%0A                                    ctx.render(String.valueOf(cnt.addAndGet(1)))%0A                                )
 )%0A              

increment added