package org.analogweb.helloworld;

import java.net.URI;

import org.analogweb.Renderable;
import org.analogweb.annotation.Bean;
import org.analogweb.annotation.RequestFormats;
import org.analogweb.annotation.Route;
import org.analogweb.annotation.XmlType;
import org.analogweb.core.MediaTypes;
import org.analogweb.core.httpserver.HttpServers;
import org.analogweb.core.response.HttpStatus;
import org.analogweb.core.response.Text;
import org.analogweb.core.response.Xml;
import org.analogweb.helloworld.annotations.UserAgent;
import org.analogweb.util.logging.Log;
import org.analogweb.util.logging.Logs;

/**
 * Hello Analog Web World!
 * @author snowgoose
 */
@Route("/")
public class HelloWorld {

    private static final Log log = Logs.getLog(HelloWorld.class);

    public static void main(String... args) {
        HttpServers.create(URI.create("http://localhost:8080")).start();
    }

    @Route
    public Text helloworld() {
        log.info("hello world!");
        return Text.with("Hello World");
    }

    @Route
    public Text helloUserAgent(@UserAgent String userAgent) {
        return Text.with("Hello World " + userAgent);
    }

    @Route
    public Xml helloXml() {
        FooBean foo = new FooBean();
        return Xml.as(foo);
    }

    @Route
    @RequestFormats(MediaTypes.APPLICATION_XML)
    public Renderable helloXmlValue(@XmlType FooBean foo) {
        if(foo == null){
            return HttpStatus.BAD_REQUEST.byReasonOf("XML entity required.");
        }
        return Text.with("Hello World " + foo.getBaa());
    }

    @Route
    public Xml helloBean(@Bean FooBean foo) {
        return Xml.as(foo);
    }
}

@@ -121,16 +121,62 @@
 n.Bean;%0A
+import org.analogweb.annotation.PathVariable;%0A
 import o
@@ -1050,32 +1050,259 @@
 World%22);%0A    %7D%0A%0A
+    @Route(%22hello/%7Bname%7D/world%22)%0A    public Text helloworld(@PathVariable(%22name%22) String name) %7B%0A        log.info(String.format(%22hello %25s world!%22, name));%0A        return Text.with(String.format(%22Hello %25s World%22, name));%0A    %7D%0A%0A
     @Route%0A    p
@@ -1375,32 +1375,46 @@
 eturn Text.with(
+String.format(
 %22Hello World %22 +
@@ -1410,19 +1410,20 @@
 o World 
-%22 +
+%25s%22,
  userAge
@@ -1425,16 +1425,17 @@
 erAgent)
+)
 ;%0A    %7D%0A
@@ -1675,16 +1675,17 @@
       if
+ 
 (foo == 
@@ -1689,16 +1689,17 @@
 == null)
+ 
 %7B%0A      

Add method