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
}
type ResponseJson struct {
TaskId string `json:"task_id"`
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"`
ResultCode int32 `json:"task_code"`
Task ResponseTask `json:"task"`
Output []byte `json:"output"`
}
type ResponseTask struct {
TaskId string `json:"task_id"`
//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 {
......@@ -1334,44 +1340,28 @@ func syncOrAsyncReturn(c *fiber.Ctx, resAsPb pbUpstream.TaskResponse, reqTaskId
func Return(c *fiber.Ctx, resAsPb pbUpstream.TaskResponse) error {
// if resAsPb.TaskIsSucceed {
// return c.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,
//TaskResultCode: resAsPb.TaskResultCode,
Task: ResponseTask{
TaskId: resAsPb.TaskId,
TaskUid: resAsPb.TaskUid,
TaskFee: resAsPb.TaskFee,
IsSuccess: resAsPb.TaskIsSucceed,
TaskError: resAsPb.TaskError,
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)
}
// 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