package cd.casic.ci.api;

import cd.casic.ci.process.engine.manager.LoggerManager;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;

@RestController
@RequestMapping("/sse")
public class SSEController {
    @Resource
    private LoggerManager loggerManager;
    @GetMapping("/subscribe/log/{taskId}")
    public SseEmitter log(HttpServletRequest request,@PathVariable String taskId){
        return loggerManager.subscribe(taskId, request);
    }
}
