所有 /api/*
接口需要通过 Bearer Token
方式验证权限,亦即:每个请求 Header 须携带
Authorization: Bearer {sha256_of_password}
sha256_of_password
的加密规则,与 storage/users_storage.go
中的 PasswordBase58Hash()
保持同步
接受参数:
dest_url
目标链接,必填memo
备注信息,选填
请求示例:
curl --request POST \
--url http://localhost:9092/api/url \
--header 'Authorization: Bearer EZ2zQjC3fqbkvtggy9p2YaJiLwx1kKPTJxvqVzowtx6t' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data dest_url=http://localhost:9092/admin/dashboard \
--data memo=dashboard
返回结果:
{
"code": 200,
"status": true,
"message": "success",
"result": {
"short_url": "http://localhost:9091/BUUtpbGp"
},
"date": "2022-04-10T21:31:29.36559+08:00"
}
接受参数:
url
path 参数,指定短链接,必填enable
禁用时,传入 false;启用时,传入 true
请求示例:
curl --request PUT \
--url http://localhost:9092/api/url/33R5QUtD/change_state \
--header 'Authorization: Bearer EZ2zQjC3fqbkvtggy9p2YaJiLwx1kKPTJxvqVzowtx6t' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data enable=false
返回结果:
{
"code": 200,
"status": true,
"message": "success",
"result": true,
"date": "2022-04-10T21:31:25.7744402+08:00"
}
接受参数:
url
path 参数,指定短链接,必填
请求示例:
curl --request GET \
--url http://localhost:9092/api/url/33R5QUtD \
--header 'Authorization: Bearer EZ2zQjC3fqbkvtggy9p2YaJiLwx1kKPTJxvqVzowtx6t' \
--header 'Content-Type: application/x-www-form-urlencoded'
返回结果:
{
"code": 200,
"status": true,
"message": "success",
"result": {
"short_url": "33R5QUtD",
"today_count": 3,
"yesterday_count": 0,
"last_7_days_count": 0,
"monthly_count": 3,
"total_count": 3,
"d_today_count": 1,
"d_yesterday_count": 0,
"d_last_7_days_count": 0,
"d_monthly_count": 1,
"d_total_count": 1
},
"date": "2022-04-10T21:31:22.059596+08:00"
}
接受参数:
account
管理员帐号,必填password
管理员密码,必填,最小长度8
请求示例:
curl --request POST \
--url http://localhost:9092/api/account \
--header 'Authorization: Bearer EZ2zQjC3fqbkvtggy9p2YaJiLwx1kKPTJxvqVzowtx6t' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data account=hello1 \
--data password=12345678
返回结果:
{
"code": 200,
"status": true,
"message": "success",
"result": null,
"date": "2022-04-10T21:31:39.7353132+08:00"
}
接受参数:
account
path 参数,管理员帐号,必填password
管理员密码,必填,最小长度8
请求示例:
curl --request PUT \
--url http://localhost:9092/api/account/hello/update \
--header 'Authorization: Bearer EZ2zQjC3fqbkvtggy9p2YaJiLwx1kKPTJxvqVzowtx6t' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data password=world123
返回结果:
{
"code": 200,
"status": true,
"message": "success",
"result": null,
"date": "2022-04-10T21:31:32.5880538+08:00"
}
接受参数:
url
path 参数,要删除的短链接地址
(此处省略示例)