package com.nisemoe.nise.controller

import jakarta.servlet.http.HttpServletRequest
import jakarta.servlet.http.HttpServletResponse
import org.springframework.stereotype.Component
import org.springframework.web.servlet.HandlerInterceptor

@Component
class NiseApiInterceptor : HandlerInterceptor {

    override fun preHandle(request: HttpServletRequest, response: HttpServletResponse, handler: Any): Boolean {

        request.getHeader("X-NISE-API")?.let {
            if(it.toInt() < 20240218) {
                response.sendError(403, "Forbidden")
                return false
            }
        }

        return true
    }

}