- 破解短信、微博等平台字数的限制
- 短链更加友好简洁
- 方便统计URL的点击量
- 安全、不暴露访问参数
![](https://raw.githubusercontent.com/convee/shorturl/master/./shorturl.png)
go get -u github.com/convee/shorturl
cd $GOPATH/src/github.com/convee/shorturl
go build -o shorturl //构建
./shorturl -addr 127.0.0.1:8002 //监听本地8002端口
curl http://127.0.0.1:8002/genUrl?url=https://convee.cn
{
"error": 0,
"msg": "ok",
"data": {
"url": "https://convee.cn",
"short": "abc"
}
}
{
"error": 1,
"msg": "no result",
"data": null
}
curl http://127.0.0.1:8002/getUrl?short=abc1
{
"error": 0,
"msg": "ok",
"data": {
"url": "https://convee.cn",
"short": "abc"
}
}
{
"error": 1,
"msg": "no result",
"data": null
}
curl http://127.0.0.1:8002/abc1