Skip to content

Commit 32378a7

Browse files
committed
bugfix
1 parent a3d939a commit 32378a7

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
# 设置示例
55
```
6-
test=>http://192.168.8.8:8080
7-
dev=>http://192.168.8.6:8888
6+
test=>192.168.8.8:8080
7+
dev=>192.168.8.6:8888
88
99
假如服务域名为 dev.com 映射如下
1010
dev.com/test/product/list => http://192.168.8.8:8080/product/list
@@ -13,6 +13,7 @@ dev.com/dev/order/list => http://192.168.8.6:8888/order/list
1313
注意:
1414
1.每行为一个映射
1515
2.dev.com机器能访问 IP 192.168.8.8
16+
3.目前只能代理http服务
1617
```
1718

1819
# 使用方法

proxy.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func (p *proxy) admin(w http.ResponseWriter, r *http.Request) {
3030
if len(d) < 2 {
3131
continue
3232
}
33-
_, err := url.Parse(d[1])
33+
_, err := url.Parse("http://" + d[1])
3434
if err != nil {
3535
fmt.Println(err.Error())
3636
continue
@@ -44,10 +44,10 @@ func (p *proxy) admin(w http.ResponseWriter, r *http.Request) {
4444
if service == "" {
4545
continue
4646
}
47-
newData = service + "=>" + newUrl
47+
newData = newData + service + "=>" + newUrl + "\n"
4848
}
4949
w.Header().Set("Content-Type", "text/html;charset=utf-8")
50-
w.Write([]byte("<form method=\"POST\"><center><textarea placeholder=\"test=>http://192.168.8.8:8080\r\n效果:\r\n" + GetURL(r) + "/test/product/list => http://192.168.8.8:8080/product/list\" autofocus name=\"data\" rows=\"30\" cols=\"100\">" + newData + "</textarea><br><input type=\"submit\" value=\"提交\"></center></form>"))
50+
w.Write([]byte("<form method=\"POST\"><center><textarea placeholder=\"test=>192.168.8.8:8080\r\n效果:\r\n" + GetURL(r) + "/test/product/list => http://192.168.8.8:8080/product/list\" autofocus name=\"data\" rows=\"30\" cols=\"100\">" + newData + "</textarea><br><input type=\"submit\" value=\"提交\"></center></form>"))
5151
}
5252

5353
func (p *proxy) ServeHTTP(w http.ResponseWriter, r *http.Request) {

0 commit comments

Comments
 (0)