MCPcopy Create free account
hub / github.com/Done-0/gin-scaffold / TestStream

Method TestStream

pkg/serve/controller/test_controller.go:157–177  ·  view source on GitHub ↗

TestStream handles simple SSE streaming test endpoint @Router /api/v1/test/testStream [post]

(c *gin.Context)

Source from the content-addressed store, hash-verified

155// TestStream handles simple SSE streaming test endpoint
156// @Router /api/v1/test/testStream [post]
157func (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}

Callers

nothing calls this directly

Calls 6

FailFunction · 0.92
NewFunction · 0.92
KVFunction · 0.92
ValidateFunction · 0.92
TestStreamMethod · 0.65
StreamToClientMethod · 0.65

Tested by

no test coverage detected