From c452d0a1d1eef937b13edc6c157d46c7ef06576c Mon Sep 17 00:00:00 2001 From: Liujian <824010343@qq.com> Date: Fri, 8 Jan 2021 14:17:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=8E=A5=E5=8F=A3=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E5=A4=B1=E8=B4=A5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/version/version.go | 2 +- go.mod | 2 +- node/gateway/application/backend/layer.go | 4 +++- server/dao/console-sqlite3/api.go | 6 +++--- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/common/version/version.go b/common/version/version.go index 07c258fb..2803919b 100644 --- a/common/version/version.go +++ b/common/version/version.go @@ -1,4 +1,4 @@ package version //Version 版本号 -const Version = "3.1.1" +const Version = "3.1.4" diff --git a/go.mod b/go.mod index 2e441941..6c6d67cc 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/eolinker/goku-api-gateway -go 1.12 +go 1.15 require ( github.com/cosiner/argv v0.0.1 // indirect diff --git a/node/gateway/application/backend/layer.go b/node/gateway/application/backend/layer.go index 3c5faeb9..180e5137 100644 --- a/node/gateway/application/backend/layer.go +++ b/node/gateway/application/backend/layer.go @@ -41,7 +41,9 @@ func (b *Layer) Send(deadline context.Context, ctx *common.Context, variables *i path := b.Path.Execution(variables) body := b.Body.Execution(variables) method := b.Method - + if method == "FOLLOW" { + method = ctx.ProxyRequest.Method + } r, finalTargetServer, retryTargetServers, err := b.Balance.Send(ctx, b.Protocol, method, path, ctx.ProxyRequest.Querys(), ctx.ProxyRequest.Headers(), []byte(body), b.TimeOut, b.Retry) if err != nil { diff --git a/server/dao/console-sqlite3/api.go b/server/dao/console-sqlite3/api.go index 4da2032f..55b45727 100644 --- a/server/dao/console-sqlite3/api.go +++ b/server/dao/console-sqlite3/api.go @@ -35,7 +35,7 @@ func (d *APIDao) AddAPI(apiName, alias, requestURL, targetURL, requestMethod, ta db := d.db now := time.Now().Format("2006-01-02 15:04:05") Tx, _ := db.Begin() - res, err := Tx.Exec("INSERT INTO goku_gateway_api (projectID,groupID,apiName,alias,requestURL,targetURL,requestMethod,targetMethod,protocol,linkAPIs,staticResponse,responseDataType,balanceName,isFollow,timeout,retryCount,alertValve,createTime,updateTime,managerID,lastUpdateUserID,createUserID,apiType) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);", projectID, groupID, apiName, alias, requestURL, targetURL, requestMethod, targetMethod, protocol, linkAPIs, staticResponse, responseDataType, balanceName, isFollow, timeout, retryCount, alertValve, now, now, managerID, userID, userID, apiType) + res, err := Tx.Exec("INSERT INTO goku_gateway_api (projectID,groupID,apiName,requestURL,targetURL,requestMethod,targetMethod,protocol,linkAPIs,staticResponse,responseDataType,balanceName,isFollow,timeout,retryCount,alertValve,createTime,updateTime,managerID,lastUpdateUserID,createUserID,apiType) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);", projectID, groupID, apiName, requestURL, targetURL, requestMethod, targetMethod, protocol, linkAPIs, staticResponse, responseDataType, balanceName, isFollow, timeout, retryCount, alertValve, now, now, managerID, userID, userID, apiType) if err != nil { Tx.Rollback() @@ -57,7 +57,7 @@ func (d *APIDao) EditAPI(apiName, alias, requestURL, targetURL, requestMethod, t db := d.db now := time.Now().Format("2006-01-02 15:04:05") Tx, _ := db.Begin() - _, err := Tx.Exec("UPDATE goku_gateway_api SET projectID = ?,groupID = ?,apiName = ?,alias = ?,requestURL = ?,targetURL = ?,requestMethod = ?,protocol = ?,balanceName = ?,targetMethod = ?,isFollow = ?,linkAPIs = ?,staticResponse = ?,responseDataType = ?,timeout = ?,retryCount = ?,alertValve = ?,updateTime = ?,managerID = ?,lastUpdateUserID = ? WHERE apiID = ?", projectID, groupID, apiName, alias, requestURL, targetURL, requestMethod, protocol, balanceName, targetMethod, isFollow, linkAPIs, staticResponse, responseDataType, timeout, retryCount, alertValve, now, managerID, userID, apiID) + _, err := Tx.Exec("UPDATE goku_gateway_api SET projectID = ?,groupID = ?,apiName = ?,requestURL = ?,targetURL = ?,requestMethod = ?,protocol = ?,balanceName = ?,targetMethod = ?,isFollow = ?,linkAPIs = ?,staticResponse = ?,responseDataType = ?,timeout = ?,retryCount = ?,alertValve = ?,updateTime = ?,managerID = ?,lastUpdateUserID = ? WHERE apiID = ?", projectID, groupID, apiName, requestURL, targetURL, requestMethod, protocol, balanceName, targetMethod, isFollow, linkAPIs, staticResponse, responseDataType, timeout, retryCount, alertValve, now, managerID, userID, apiID) if err != nil { Tx.Rollback() @@ -428,7 +428,7 @@ func (d *APIDao) BatchDeleteAPI(apiIDList string) (bool, string, error) { db := d.db now := time.Now().Format("2006-01-02 15:04:05") Tx, _ := db.Begin() - sql := "DELETE FROM goku_gateway_api A WHERE apiID IN (" + apiIDList + ");" + sql := "DELETE FROM goku_gateway_api WHERE apiID IN (" + apiIDList + ");" _, err := Tx.Exec(sql) if err != nil { Tx.Rollback() -- GitLab