package app.web;

import app.web.interceptor.Protected;
import core.framework.inject.Inject;
import core.framework.web.Request;
import core.framework.web.Response;
import core.framework.web.site.Message;

/**
 * @author neo
 */
public class IndexController {
    @Inject
    Message message;
    @Inject
    LanguageManager languageManager;

    @Protected(operation = "index")
    public Response index(Request request) {
        IndexPage model = new IndexPage();
        model.name = message.get("key.name", languageManager.language()).orElse("world not found");
        model.imageURL = "https://image.com/image123.jpg";

//        Session session = request.session();
////        Optional<String> hello = session.get("hello");
//        session.set("hello", "world");
        Response response = Response.html("/template/index.html", model, languageManager.language());
        response.cookie(Cookies.TEST, "1+2");
        response.cookie(Cookies.TEST1, "hello \"\" cookies");
        return response;
    }

    public Response submit(Request request) {
        return Response.text("hello " + request.formParam("name").orElse("nobody"));
    }

    public Response logout(Request request) {
        request.session().invalidate();
        return Response.text("logout");
    }
}

@@ -252,16 +252,98 @@
 oller %7B%0A
+    private final Logger logger = LoggerFactory.getLogger(IndexController.class);%0A
     @Inj
@@ -1128,32 +1128,61 @@
 uest request) %7B%0A
+        logger.warn(%22test%22);%0A
         return R

refactor http logging, mask request session cookie logging