Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
apaas-meshproxy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gzga-jzapi
apaas-meshproxy
Commits
f77c3f1b
Commit
f77c3f1b
authored
Nov 06, 2019
by
gaoshiyao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新路由设置
parent
6e6512f7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
12 deletions
+25
-12
src/handler/proxyhandler.go
src/handler/proxyhandler.go
+25
-12
No files found.
src/handler/proxyhandler.go
View file @
f77c3f1b
...
...
@@ -3,12 +3,12 @@ package handler
import
(
"fmt"
"github.com/gin-gonic/gin"
"github.com/sirupsen/logrus"
"gitlab.wodcloud.com/apaas/apaas-meshproxy/src/client"
"gitlab.wodcloud.com/apaas/apaas-meshproxy/src/tools"
"net/http"
"strings"
"github.com/vulcand/oxy/forward"
"github.com/vulcand/oxy/testutils"
"gitlab.wodcloud.com/apaas/apaas-meshproxy/src/config"
)
...
...
@@ -24,16 +24,29 @@ func Proxy(c *gin.Context) {
c
.
String
(
200
,
"缓存计数失败!"
)
return
}
req
:=
c
.
Request
baseUrl
:=
"http://"
+
req
.
Host
+
req
.
URL
.
Path
req
.
URL
=
testutils
.
ParseURI
(
getProxyURL
(
req
))
req
.
RequestURI
=
getRequestURI
(
req
)
req
.
Host
=
req
.
URL
.
Host
logrus
.
Info
(
"************************************"
)
logrus
.
Info
(
"* 调用地址:"
,
baseUrl
)
logrus
.
Info
(
"* 转发地址:"
,
req
.
URL
)
logrus
.
Info
(
"************************************"
)
fwd
.
ServeHTTP
(
c
.
Writer
,
req
)
var
result
[]
byte
var
err
error
switch
strings
.
ToUpper
(
config
.
ProxyConf
.
Method
)
{
case
"GET"
:
result
,
err
=
tools
.
ProxySend
(
c
.
Request
,
"GET"
,
config
.
ProxyConf
.
Url
,
""
,
nil
)
}
if
err
!=
nil
{
c
.
Error
(
err
)
return
}
c
.
Writer
.
Write
(
result
)
//
//req := c.Request
//baseUrl := "http://" + req.Host + req.URL.Path
//req.URL = testutils.ParseURI(getProxyURL(req))
//req.RequestURI = getRequestURI(req)
//req.Host = req.URL.Host
//logrus.Info("************************************")
//logrus.Info("* 调用地址:", baseUrl)
//logrus.Info("* 转发地址:", req.URL)
//logrus.Info("************************************")
//fwd.ServeHTTP(c.Writer, req)
}
func
getProxyURL
(
req
*
http
.
Request
)
string
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment