package com.alterdekim.game.controller;

import com.alterdekim.game.service.GoodsService;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import java.io.File;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;

@Slf4j
@Controller
public class StaticController {

    @Autowired
    private GoodsService goodsService;


    @GetMapping("/main")
    public String mainPage() {
        return "main";
    }

    @GetMapping("/")
    public String defPage() {
        return "index";
    }

    @GetMapping("/push")
    public String pushPage() {
        return "db";
    }

    @GetMapping("/crossdomain.xml")
    public ResponseEntity<String> crossdomain() {
        return ResponseEntity.ok().contentType(MediaType.APPLICATION_XML).body("<?xml version=\"1.0\" ?>\n" +
                "<cross-domain-policy>\n" +
                "  <site-control permitted-cross-domain-policies=\"all\"/>\n" +
                "  <allow-access-from domain=\"*\"/>\n" +
                "  <allow-http-request-headers-from domain=\"*\" headers=\"*\"/>\n" +
                "</cross-domain-policy>\n");
    }

}