xtt28/shortener
Instantly generate shortened links online with custom aliases.
Features
- Highly performant and optimized
- Users can create custom aliases for links
- Responsive user interface
- Supports sharing via native share sheet
- Supports HTTPS
Screenshots
Badges
Run Locally
- Clone the project:
git clone https://github.com/xtt28/shortener
- Switch to the project directory:
cd shortener
- Create your
.env
file (see the Environment Variables section)
- Start the server:
go run .
- Go to http://localhost:8080 in your web browser
Running Tests
To run tests, run the following command:
go test ./...
Environment Variables
To run this project, you will need to add the following environment variables to your .env file:
ROOT
- the URL to your instance
PORT
- the port to run your instance on
TLS
The following environment variables concern TLS:
TLS_ENABLED
- whether to enable TLS
TLS_CERT
- the path to the TLS certificate file
TLS_KEY
- the path to the TLS key file
Please refer to the template.env
file for an example.
API Reference
Create new shortened link
POST /api/create
Parameter |
Type |
Description |
destination |
string |
Required. The URL to make the short link resolve to. |
alias |
string |
An alias that can be used in addition to your link's ID when sharing it. |
Redirect to short link destination
GET /v/${id}
Parameter |
Type |
Description |
id |
string |
Required. The ID of the shortened link. |
Tech
Client: Bootstrap, htmx
Server: Go, Gin, GORM, SQLite
Contributing
Contributions are always welcome. Please:
- write tests for your code;
- run it through
go fmt
and go vet
.
License
MIT