package de.htwsaar.webshop.controller;

import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import static de.htwsaar.webshop.config.ControllerPathConfig.HARDCODE_IMAGE_DPS_STICKER;
import static de.htwsaar.webshop.util.LoggerUtil.logRequest;

@RestController
@Slf4j
public class ImageHardcodeController {
    private final ResourceLoader resourceLoader;

    @Autowired
    public ImageHardcodeController(ResourceLoader resourceLoader) {
        this.resourceLoader = resourceLoader;
    }

    @RequestMapping(value = HARDCODE_IMAGE_DPS_STICKER, method = RequestMethod.GET)
    Resource dpsSticker(HttpServletRequest request) {
        logRequest(request);
        return resourceLoader.getResource("classpath:images/dps_sticker.webp");
    }
}
