<commit_before>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"));
    }
    
}<commit_msg>fix for problem with trailing slashes in request urls (#84)<commit_after>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.debug("API call to '" + req.pathInfo() + "'"));
        before((req, res) -> {
           String path = req.pathInfo();
           if (path.endsWith("/")) {
               String newPath = path.substring(0, path.length() - 1);
               LOGGER.debug("Call to '" + path + "' redirected to '" + newPath + "'");
               res.redirect(newPath);
           }
        });
        
        get("/hello", (req, res) -> "Hello World");
        get("/hello/:name", (req, res) -> "Hello " + req.params(":name"));
    }
    
}
{'fraction_non_alphanumeric': 0.15137346580946814, 'fraction_numerical': 0.004675628287551139, 'mean_word_length': 2.596638655462185, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6738564', 'n_tokens_mistral': 517, 'n_tokens_neox': 516, 'n_words': 118}