https://github.com/long2ice/longurl
A self-hosted short url service
https://github.com/long2ice/longurl
entgo fiber go short-url url-shortener
Last synced: 3 months ago
JSON representation
A self-hosted short url service
- Host: GitHub
- URL: https://github.com/long2ice/longurl
- Owner: long2ice
- License: apache-2.0
- Created: 2021-10-30T02:24:18.000Z (over 3 years ago)
- Default Branch: dev
- Last Pushed: 2023-09-15T07:12:37.000Z (over 1 year ago)
- Last Synced: 2025-01-14T03:22:11.308Z (3 months ago)
- Topics: entgo, fiber, go, short-url, url-shortener
- Language: Go
- Homepage: https://longurl.long2ice.io
- Size: 337 KB
- Stars: 52
- Watchers: 4
- Forks: 6
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome - long2ice/longurl - A self-hosted short url service (Go)
- awesome-ops - long2ice/longurl - 2.0|52|2021-10-30|2023-09-15 | 一个自托管的短链服务 | (ShortURL)
- awesome-github-star - longurl - hosted short url service | long2ice | 48 | (Go)
README
# longurl
[](https://github.com/long2ice/longurl/actions/workflows/deploy.yml)
[](https://pkg.go.dev/github.com/long2ice/longurl)
## Introduction
`longurl` is a self-hosted short url service.
## Try It Out
```shell
curl -H "Content-Type:application/json" -X POST --data '{"url": "https://github.com/long2ice/longurl"}' https://longurl.long2ice.io
```Return like this:
```json
{
"url": "https://longurl.long2ice.io/3FXrsHE"
}
```Now Visit .
### Params
- `url` (required): the url to be shorted.
- `path` (optional): the custom path for short url, can config allow or not.
- `expire_at` (optional): when the short url expire, can set default expire in config.
- `max_times` (optional): max times access, shorted url will be invalid if reached.## Deploy
First write a `config.yaml`.
```yaml
server:
host: 0.0.0.0
port: 3000
logTimezone: Asia/Shanghai
logTimeFormat: 2006-01-02 15:04:05.000000
url:
domain: localhost:3000
schema: http
length: 7 # the path length
allowCustomPath: true # allow custom short url path
expireSeconds: 2592000 # default expire seconds
unique: true # same urls only generate one short url
database:
type: mysql
dsn: root:123456@tcp(127.0.0.1:3306)/longurl?parseTime=true
```Then run with `docker`.
```shell
docker run -d -p 3000:3000 --name longurl -v /config.yaml:/config/config.yaml ghcr.io/long2ice/longurl/longurl
```You can visit to see the API docs.
## Frontend
The frontend project is [https://github.com/long2ice/longurl-web](https://github.com/long2ice/longurl-web).
## Credits
- [Fiber](https://github.com/gofiber/fiber), Express inspired web framework written in Go.
- [Ent](https://github.com/ent/ent), An entity framework for Go.
- [Sonyflake](https://github.com/sony/sonyflake), A distributed unique ID generator inspired by Twitter's Snowflake.## License
This project is licensed under the
[Apache-2.0](https://github.com/long2ice/longurl/blob/master/LICENSE)
License.