Skip to content

Commit

Permalink
gord
Browse files Browse the repository at this point in the history
  • Loading branch information
ixre committed Jun 14, 2017
1 parent 80949b8 commit efab274
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@

## 应用场景 ##
1. 做301跳转
2. 短域名,比如:to2.net/blog 跳转到我的博客http://www.s1n1.com
2. 短域名,比如:to2.net/git 跳转到 http://github.com/jsix

## 配置 ##
配置文件后缀为*.conf,启动时会加载改目录下的所有配置。 默认加载根目录下的配置。
配置文件为: *.conf,启动时会加载目录(默认为当前目录,可以通过dir参数指定)下的所有配置。

host项支持通配,如: *.to2.net 能匹配 to2.net的所有子域名

## 启动 ##
./gord -dir=./ -port=8032

./gord

第一次运行会生成一个默认的配置示例:

[
Expand All @@ -20,11 +22,12 @@ host项支持通配,如: *.to2.net 能匹配 to2.net的所有子域名
"to": "http://www.to2.net/{path}{query}",
"location": {
"/1/2/3/": "http://a.com/{#0}-{#1}-{#2}",
"/a": "http://a.com",
"/a/b": "http://a.com/{path}{query}",
"/b/*": "http://b.com/{*}"
"/a": "http://a.com/{path}{query}",
"/b/*": "http://b.com/t-{*}"
}
}
]



3 changes: 1 addition & 2 deletions example.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
"to": "http://www.to2.net/{path}{query}",
"location": {
"/1/2/3/": "http://a.com/{#0}-{#1}-{#2}",
"/a": "http://a.com",
"/a/b": "http://a.com/{path}{query}",
"/a": "http://a.com/{path}{query}",
"/b/*": "http://b.com/t-{*}"
}
}
Expand Down
5 changes: 2 additions & 3 deletions gord.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,8 @@ func (i *ItemManager) initExample() {
Host: "*.to2.net",
To: "http://www.to2.net/{path}{query}",
Location: map[string]string{
"/a": "http://a.com",
"/a": "http://a.com/{path}{query}",
"/b/*": "http://b.com/t-{*}",
"/a/b": "http://a.com/{path}{query}",
"/1/2/3/": "http://a.com/{#0}-{#1}-{#2}",
},
},
Expand Down Expand Up @@ -219,7 +218,7 @@ type redirectHandler struct {

func (r *redirectHandler) ServeHTTP(rsp http.ResponseWriter, req *http.Request) {
host := req.Host
// host = "www.to2.net" // "z3q.net" use for test
// host = "www.to2.net" // "to2.net" use for test
var item *Item = r.itemManager.GetItemByHost(host)
if item != nil {
if location, b := r.getLocation(rsp, req, item); b {
Expand Down

0 comments on commit efab274

Please sign in to comment.