fix(#1): 🚑 Fix application stopping early (#4)

Co-authored-by: Daniel Sy <Daniel.Sy@t-systems.com>
Reviewed-on: https://forgejo.edf-bootstrap.cx.fg1.ffm.osc.live/Daniel.Sy/loic-go/pulls/4
This commit is contained in:
Daniel.Sy 2025-03-28 02:56:49 +00:00
parent e151b4a6e1
commit 483484e2e2
3 changed files with 16 additions and 4 deletions

View file

@ -23,6 +23,10 @@ func Start() {
})
r.POST("/start", func(c *gin.Context) {
if c.Request.Method != http.MethodPost {
http.Error(c.Writer, "Invalid request method", http.StatusMethodNotAllowed)
return
}
targetURL := c.PostForm("target_url")
concurrency, _ := strconv.Atoi(c.PostForm("concurrency"))
duration, _ := time.ParseDuration(c.PostForm("duration"))
@ -33,6 +37,10 @@ func Start() {
})
r.POST("/stop", func(c *gin.Context) {
if c.Request.Method != http.MethodPost {
http.Error(c.Writer, "Invalid request method", http.StatusMethodNotAllowed)
return
}
loic.StopTest()
c.Redirect(http.StatusSeeOther, "/")
})