package click.kamil.examples.statemachine.extended.web;

import lombok.RequiredArgsConstructor;
import org.springframework.statemachine.StateMachine;
import org.springframework.web.servlet.HandlerInterceptor;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

@RequiredArgsConstructor
public class AuditInterceptor implements HandlerInterceptor {

    private final StateMachine<String, String> stateMachine;

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
        stateMachine.sendEvent("AUDIT_EVENT");
        return true;
    }
}
