package com.samsung.common.controller;

import org.springframework.boot.web.servlet.error.ErrorController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;

import jakarta.servlet.http.HttpServletRequest;

@Controller
public class SdlErrorController implements ErrorController{
    @GetMapping("/error")
    public String getHandleError(HttpServletRequest request){
        return "forward:/index.html?redirect=" + request.getRequestURI();
    }

    @PostMapping("/error")
    public String postHandleError(HttpServletRequest request){
        return "forward:/index.html?redirect=" + request.getRequestURI();
    }

    @PutMapping("/error")
    public String putHandleError(HttpServletRequest request){
        return "forward:/index.html?redirect=" + request.getRequestURI();
    }

    @DeleteMapping("/error")
    public String deleteHandleError(HttpServletRequest request){
        return "forward:/index.html?redirect=" + request.getRequestURI();
    }
}