fix API redirect

This commit is contained in:
Alexander Baryshnikov 2020-12-08 20:18:33 +08:00
parent d031b5ff3b
commit b50437c125
3 changed files with 13 additions and 5 deletions

View File

@ -2,7 +2,7 @@
![nano-run](https://user-images.githubusercontent.com/6597086/97143787-4f70db80-179e-11eb-9b9c-7e16bfff845e.png)
Lightweight async request runner.
Lightweight async request runner. GitOps friendly.
A simplified version of [trusted-cgi](https://github.com/reddec/trusted-cgi) designed
for async processing extreme amount of requests.
@ -23,6 +23,14 @@ Please note that the project is being developed in free time, as a non-profitabl
All codes, bugs, opinions, and other related subjects should not be considered as the official position, official project,
or company-backed project to any of the companies for/with which I worked before or/and at present.
TODO:
* On attempt failed job
* On failed job
* On success job
* Per endpoint swagger
* Pickup file as an artifact
![sample-nano-run](https://user-images.githubusercontent.com/6597086/98463432-303e6900-21f6-11eb-9632-806b1c99813b.gif)

View File

@ -31,7 +31,7 @@ func Expose(router gin.IRouter, wrk *worker.Worker, defaultWaitTime time.Duratio
return
}
gctx.Header("X-Correlation-Id", id)
gctx.Redirect(http.StatusSeeOther, id)
gctx.Redirect(http.StatusSeeOther, id+"?"+gctx.Request.URL.RawQuery)
})
router.PUT("/", handler.createSyncTask)
taskRoutes := router.Group("/:id")
@ -73,7 +73,7 @@ func (wh *workerHandler) createSyncTask(gctx *gin.Context) {
gctx.Header("X-Correlation-Id", tracker.ID())
select {
case <-tracker.Done():
gctx.Redirect(http.StatusSeeOther, tracker.ID()+"/completed")
gctx.Redirect(http.StatusSeeOther, tracker.ID()+"/completed?"+gctx.Request.URL.RawQuery)
case <-time.After(queryParams.Wait):
gctx.AbortWithStatus(http.StatusGatewayTimeout)
}
@ -122,7 +122,7 @@ func (wh *workerHandler) retry(gctx *gin.Context) {
return
}
gctx.Header("X-Correlation-Id", id)
gctx.Redirect(http.StatusSeeOther, id)
gctx.Redirect(http.StatusSeeOther, id+"?"+gctx.Request.URL.RawQuery)
}
func (wh *workerHandler) completeRequest(gctx *gin.Context) {

File diff suppressed because one or more lines are too long