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: 9 months 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 (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2025-04-10T03:34:45.000Z (about 1 year ago)
- Last Synced: 2025-04-10T04:34:45.412Z (about 1 year 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.77 MB
- Stars: 13
- Watchers: 4
- 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
English|[中文文档](README-ZH.md)
[](https://pkg.go.dev/github.com/houseme/url-shortenter)
[](https://github.com/houseme/url-shortenter/actions/workflows/go.yml)
[](https://github.com/houseme/url-shortenter)

A short link service system suitable for small and medium-sized community websites.
Supports short link generation, query, 302 redirection, click statistics, independent IP statistics, and access log query.
## Quick Start
```shell
go install -u -v github.com/houseme/url-shortenter@latest
```
## Console Default Account
Default account: `shortenter`
Default password: `B9Mazv5M2J6%1zU2@nxC`
The database stores encrypted passwords, which are annotated in `document\structure.sql`. If you need to customize other passwords, you can modify them here.
Encryption rules are in `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 Support
### `/api` Interface Permission Description
All `/console/api/*` interfaces require `Bearer Token` authentication. That is, each request header must include:
```shell
Authorization: Bearer {sha256_of_password}
```
### 1. Add Short Link `POST /api/url`
## Short Link Generation Code
Located in `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.
## Thanks
