Commit 83e2a55f authored by Cloud User's avatar Cloud User

fix http response

parent eb44aa60
...@@ -597,13 +597,19 @@ func batchToQuestDb(done chan interface{}, reqStream chan pbUpstream.TaskContent ...@@ -597,13 +597,19 @@ func batchToQuestDb(done chan interface{}, reqStream chan pbUpstream.TaskContent
} }
type ResponseJson struct { type ResponseJson struct {
TaskId string `json:"task_id"` Task ResponseTask `json:"task"`
TaskResult []byte `json:"task_result"` Output []byte `json:"output"`
TaskUid string `json:"task_uid"` }
TaskFee string `json:"task_fee"`
IsSuccess bool `json:"is_success"` type ResponseTask struct {
TaskError string `json:"task_error"` TaskId string `json:"task_id"`
ResultCode int32 `json:"task_code"` //TaskResult []byte `json:"task_result"`
TaskUid string `json:"task_uid"`
TaskFee string `json:"task_fee"`
IsSuccess bool `json:"is_success"`
TaskError string `json:"task_error"`
ExecCode int32 `json:"exec_code"`
// "exec_code":"",
} }
func newCache(redisAddr, redisPass, mysqlIP, dbName, user, passwd string, port int) *cachedata.CacheData { func newCache(redisAddr, redisPass, mysqlIP, dbName, user, passwd string, port int) *cachedata.CacheData {
...@@ -1334,44 +1340,28 @@ func syncOrAsyncReturn(c *fiber.Ctx, resAsPb pbUpstream.TaskResponse, reqTaskId ...@@ -1334,44 +1340,28 @@ func syncOrAsyncReturn(c *fiber.Ctx, resAsPb pbUpstream.TaskResponse, reqTaskId
func Return(c *fiber.Ctx, resAsPb pbUpstream.TaskResponse) error { func Return(c *fiber.Ctx, resAsPb pbUpstream.TaskResponse) error {
// if resAsPb.TaskIsSucceed {
// return c.Send(resAsPb.GetTaskResultBody())
// }
//fmt.Println("syncMode-------------", syncMode)
resAsJson := ResponseJson{ resAsJson := ResponseJson{
TaskId: resAsPb.TaskId, Task: ResponseTask{
TaskResult: resAsPb.GetTaskResultBody(), TaskId: resAsPb.TaskId,
TaskUid: resAsPb.TaskUid, TaskUid: resAsPb.TaskUid,
TaskFee: resAsPb.TaskFee, TaskFee: resAsPb.TaskFee,
IsSuccess: resAsPb.TaskIsSucceed, IsSuccess: resAsPb.TaskIsSucceed,
TaskError: resAsPb.TaskError, TaskError: resAsPb.TaskError,
//TaskResultCode: resAsPb.TaskResultCode, ExecCode: resAsPb.TaskResultCode,
},
Output: resAsPb.GetTaskResultBody(),
} }
// resAsJson := ResponseJson{
// TaskId: resAsPb.TaskId,
// TaskResult: resAsPb.GetTaskResultBody(),
// TaskUid: resAsPb.TaskUid,
// TaskFee: resAsPb.TaskFee,
// IsSuccess: resAsPb.TaskIsSucceed,
// TaskError: resAsPb.TaskError,
// //TaskResultCode: resAsPb.TaskResultCode,
// }
return c.JSON(resAsJson) return c.JSON(resAsJson)
} }
// func redirectReturn(c *fiber.Ctx, resAsPb pbUpstream.TaskResponse) error {
// //c.Status(int(resAsPb.TaskResultCode)).Response().Header.SetL
// if resAsPb.TaskIsSucceed {
// return c.Status(int(resAsPb.TaskResultCode)).Send(resAsPb.GetTaskResultBody())
// }
// //fmt.Println("syncMode-------------", syncMode)
// resAsJson := ResponseJson{
// TaskId: resAsPb.TaskId,
// TaskResult: resAsPb.GetTaskResultBody(),
// TaskUid: resAsPb.TaskUid,
// TaskFee: resAsPb.TaskFee,
// IsSuccess: resAsPb.TaskIsSucceed,
// TaskError: resAsPb.TaskError,
// }
// return c.Status(int(resAsPb.TaskResultCode)).JSON(resAsJson)
// }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment