package hello.controllers;

import hello.models.Greeting;
import leap.core.validation.annotations.Required;
import leap.web.annotation.DefaultValue;
import leap.web.annotation.http.GET;
import leap.web.api.mvc.ApiController;
import leap.web.api.mvc.ApiResponse;
import java.util.concurrent.atomic.AtomicInteger;

public class GreetingController extends ApiController {

    private static final AtomicInteger counter = new AtomicInteger();

    @GET
    public ApiResponse<Greeting> greeting(@Required @DefaultValue("World") String name) {
        return ApiResponse.of(new Greeting(counter.incrementAndGet(), String.format("Hello, %s!", name)));
    }

}
@@ -51,16 +51,153 @@
 eeting;%0A
+import leap.core.security.SecurityContext;%0Aimport leap.core.security.UserPrincipal;%0Aimport leap.core.security.annotation.AllowAnonymous;%0A
 import l
@@ -238,16 +238,41 @@
 quired;%0A
+import leap.web.Request;%0A
 import l
@@ -416,16 +416,71 @@
 esponse;
+%0A%0Aimport java.util.LinkedHashMap;%0Aimport java.util.Map;
 %0Aimport 
@@ -750,16 +750,16 @@
 name) %7B%0A
-
         
@@ -864,9 +864,1153 @@
 %0A    %7D%0A%0A
+    @GET(%22/anonymous%22)%0A    @AllowAnonymous%0A    public ApiResponse%3CGreeting%3E greetingAnonymous(@Required @DefaultValue(%22World%22) String name) %7B%0A        return ApiResponse.of(new Greeting(counter.incrementAndGet(), String.format(%22Hello, %25s!%22, name)));%0A    %7D%0A%0A    @GET(%22/userinfo1%22)%0A    public ApiResponse%3CMap%3CString,Object%3E%3E userinfo1(UserPrincipal user) %7B%0A        return ApiResponse.of(map(user));%0A    %7D%0A%0A    @GET(%22/userinfo2%22)%0A    public ApiResponse%3CMap%3CString,Object%3E%3E userinfo2(Request request) %7B%0A        return ApiResponse.of(map(request.getUser()));%0A    %7D%0A%0A    @GET(%22/userinfo3%22)%0A    public ApiResponse%3CMap%3CString,Object%3E%3E userinfo3() %7B%0A        return ApiResponse.of(map(Request.current().getUser()));%0A    %7D%0A%0A    @GET(%22/userinfo4%22)%0A    public ApiResponse%3CMap%3CString,Object%3E%3E userinfo4() %7B%0A        return ApiResponse.of(map(SecurityContext.user()));%0A    %7D%0A%0A    protected Map%3CString,Object%3E map(UserPrincipal user) %7B%0A        Map%3CString,Object%3E map = new LinkedHashMap%3C%3E();%0A%0A        map.put(%22id%22,        user.getId());%0A        map.put(%22name%22,      user.getName());%0A        map.put(%22loginName%22, user.getLoginName());%0A%0A        return map;%0A    %7D%0A%0A
 %7D

add userinfo