TestStream handles simple SSE streaming test endpoint @Router /api/v1/test/testStream [post]
(c *gin.Context)
| 155 | // TestStream handles simple SSE streaming test endpoint |
| 156 | // @Router /api/v1/test/testStream [post] |
| 157 | func (tc *TestController) TestStream(c *gin.Context) { |
| 158 | req := &dto.TestStreamRequest{} |
| 159 | if err := c.ShouldBindJSON(req); err != nil { |
| 160 | c.JSON(http.StatusBadRequest, vo.Fail(c, err, errorx.New(errno.ErrInvalidParams, errorx.KV("msg", "bind JSON failed")))) |
| 161 | return |
| 162 | } |
| 163 | |
| 164 | errors := validator.Validate(req) |
| 165 | if errors != nil { |
| 166 | c.JSON(http.StatusBadRequest, vo.Fail(c, errors, errorx.New(errno.ErrInvalidParams, errorx.KV("msg", "validation failed")))) |
| 167 | return |
| 168 | } |
| 169 | |
| 170 | events, err := tc.testService.TestStream(c, req) |
| 171 | if err != nil { |
| 172 | c.JSON(http.StatusInternalServerError, vo.Fail(c, err, errorx.New(errno.ErrInternalServer))) |
| 173 | return |
| 174 | } |
| 175 | |
| 176 | _ = tc.sseManager.StreamToClient(c, events) |
| 177 | } |
nothing calls this directly
no test coverage detected