package org.codiki.core.config;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@RestController
public class RobotsTxtController {
    private static final Logger LOG = LoggerFactory.getLogger(RobotsTxtController.class);

    @RequestMapping(value = "/robots.txt")
    public void robots(HttpServletResponse response) {
        try {
            response.getWriter().write("User-agent: *\nDisallow: /\n");
        } catch (IOException ex) {
            LOG.info("Error during robots.txt serving.", ex);
        }
    }
}
