package io.teiler.api.endpoint;

import static spark.Spark.get;
import static spark.Spark.before;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

@Component
public class HelloWorld {

    private static Logger LOGGER = LoggerFactory.getLogger(HelloWorld.class);
    
    public HelloWorld() {
        register();
    }
    
    public void register() {
        before((req, res) -> LOGGER.info("API call to " + req.pathInfo()));
        
        get("/hello", (req, res) -> "Hello World");
        get("/hello/:name", (req, res) -> "Hello " + req.params(":name"));
    }
    
}

@@ -465,12 +465,13 @@
 GER.
-info
+debug
 (%22AP
@@ -480,16 +480,17 @@
 call to 
+'
 %22 + req.
@@ -499,17 +499,360 @@
 thInfo()
-)
+ + %22'%22));%0D%0A        before((req, res) -%3E %7B%0D%0A           String path = req.pathInfo();%0D%0A           if (path.endsWith(%22/%22)) %7B%0D%0A               String newPath = path.substring(0, path.length() - 1);%0D%0A               LOGGER.debug(%22Call to '%22 + path + %22' redirected to '%22 + newPath + %22'%22);%0D%0A               res.redirect(newPath);%0D%0A           %7D%0D%0A        %7D
 );%0D%0A    

fix for problem with trailing slashes in request urls (#84)