From 44a9e5d12739d589b2dc682d587e0e3e1b1a9f38 Mon Sep 17 00:00:00 2001 From: gklp Date: Sun, 28 Jul 2019 21:00:06 +0300 Subject: [PATCH 1/2] All redirect operations should have content-type as json Signed-off-by: gklp --- src/common/api/base.go | 1 + 1 file changed, 1 insertion(+) diff --git a/src/common/api/base.go b/src/common/api/base.go index 928c37e08..bb1750a56 100644 --- a/src/common/api/base.go +++ b/src/common/api/base.go @@ -112,6 +112,7 @@ func (b *BaseAPI) Redirect(statusCode int, resouceID string) { requestURI := b.Ctx.Request.RequestURI resourceURI := requestURI + "/" + resouceID + b.Ctx.ResponseWriter.Header().Set("Content-Type", "application/json") b.Ctx.Redirect(statusCode, resourceURI) } From dee3defeff52510c1c98f1b5455273ade5f7079f Mon Sep 17 00:00:00 2001 From: gklp Date: Mon, 26 Aug 2019 14:15:03 +0300 Subject: [PATCH 2/2] refactored Signed-off-by: gklp --- src/common/api/base.go | 1 - src/core/api/robot.go | 4 ++++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/common/api/base.go b/src/common/api/base.go index bb1750a56..928c37e08 100644 --- a/src/common/api/base.go +++ b/src/common/api/base.go @@ -112,7 +112,6 @@ func (b *BaseAPI) Redirect(statusCode int, resouceID string) { requestURI := b.Ctx.Request.RequestURI resourceURI := requestURI + "/" + resouceID - b.Ctx.ResponseWriter.Header().Set("Content-Type", "application/json") b.Ctx.Redirect(statusCode, resourceURI) } diff --git a/src/core/api/robot.go b/src/core/api/robot.go index be49983a4..870310e71 100644 --- a/src/core/api/robot.go +++ b/src/core/api/robot.go @@ -161,6 +161,10 @@ func (r *RobotAPI) Post() { Name: robot.Name, Token: rawTk, } + + w := r.Ctx.ResponseWriter + w.Header().Set("Content-Type", "application/json") + r.Redirect(http.StatusCreated, strconv.FormatInt(id, 10)) r.Data["json"] = robotRep r.ServeJSON()