Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/houseme/url-shortenter
A short link service system suitable for small and medium-sized community websites. supports short link production, query and 302 redirection, and comes with click statistics, independent IP statistics and access logs.
https://github.com/houseme/url-shortenter
api authorization console golang productivity screenshot short short-link short-urls shortener shorturl shorturl-services statistics url-shortener urlshortener
Last synced: 24 days ago
JSON representation
A short link service system suitable for small and medium-sized community websites. supports short link production, query and 302 redirection, and comes with click statistics, independent IP statistics and access logs.
- Host: GitHub
- URL: https://github.com/houseme/url-shortenter
- Owner: houseme
- License: mit
- Created: 2022-07-20T05:23:28.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-04-13T16:14:30.000Z (7 months ago)
- Last Synced: 2024-04-14T12:42:01.973Z (7 months ago)
- Topics: api, authorization, console, golang, productivity, screenshot, short, short-link, short-urls, shortener, shorturl, shorturl-services, statistics, url-shortener, urlshortener
- Language: Go
- Homepage: https://houseme.github.io/url-shortenter/
- Size: 3.47 MB
- Stars: 11
- Watchers: 3
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Security: SECURITY.md
Awesome Lists containing this project
README
# URL-Shortenter
[![Go Reference](https://pkg.go.dev/badge/github.com/houseme/url-shortenter.svg)](https://pkg.go.dev/github.com/houseme/url-shortenter)
[![Url-Shortenter CI](https://github.com/houseme/url-shortenter/actions/workflows/go.yml/badge.svg)](https://github.com/houseme/url-shortenter/actions/workflows/go.yml)
[![License](https://img.shields.io/github/license/houseme/url-shortenter.svg?style=flat)](https://github.com/houseme/url-shortenter)
![GitHub go.mod Go version (branch)](https://img.shields.io/github/go-mod/go-version/houseme/url-shortenter/main)A short link service system suitable for small and medium-sized community websites.
Support short link production, query and 302 redirection, and have its own click statistics, independent IP statistics,
access log query.## 快速使用
```shell
go install -u -v github.com/houseme/url-shortenter@latest
```## Console 后台默认帐号
默认帐号:`shortenter`
默认密码:`B9Mazv5M2J6%1zU2@nxC`数据库中存储的是加密后的密码,在 `document\structure.sql` 中标有注释,如果需要自定义其他密码,可以修改这里
加密规则 `utility/helper.go` 中
```go
func (u *utilHelper) PasswordBase58Hash(password string) (string, error) {
data, err := u.Sha256OfShort(password)
if err != nil {
err = gerror.Wrap(err, "utilHelper PasswordBase58Hash Sha256OfShort error")
return "", err
}
return u.Base58Encode(data), nil
}
```## HTTP API 支持
### `/api` 接口权限说明
所有 `/console/api/*` 接口需要通过 `Bearer Token` 方式验证权限,亦即:每个请求 Header 须携带
```shell
Authorization: Bearer {sha256_of_password}
```### 1. 新增短链接 `POST /api/url`
## 短链接生产过程相关代码
所在文件 `utility/helper.go`
```go
func (u *utilHelper) GenerateShortLink(ctx context.Context, url string) (string, error) {
var (
err error
urlHash []byte
logger = u.Logger(ctx)
)
g.Log(logger).Debug(ctx, "utilHelper GenerateShortLink url:", url)
if urlHash, err = u.Sha256OfShort(url); err != nil {
err = gerror.Wrap(err, "utilHelper GenerateShortLink Sha256OfShort err")
return "", err
}
// number := new(big.Int).SetBytes(urlHash).Uint64()
// str := u.Base58Encode(gconv.Bytes(number))
str := u.Base58Encode(urlHash)
g.Log(logger).Debug(ctx, "utilHelper GenerateShortLink str:", str, " number:", number)
return str[:8], nil
}
```## License
`URL-Shortenter` is licensed under the [MIT License](LICENSE), 100% free and open-source, forever.
## Thinks