https://github.com/darthsim/shorty
Tiny url shortener
https://github.com/darthsim/shorty
Last synced: 11 months ago
JSON representation
Tiny url shortener
- Host: GitHub
- URL: https://github.com/darthsim/shorty
- Owner: DarthSim
- License: mit
- Created: 2015-02-21T19:27:51.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2015-07-29T22:22:28.000Z (almost 11 years ago)
- Last Synced: 2025-03-26T23:04:59.332Z (about 1 year ago)
- Language: Go
- Size: 243 KB
- Stars: 4
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Shorty
[](https://travis-ci.org/DarthSim/shorty)
Tiny url shortener
## Installation
You will need Go and [Gom](https://github.com/mattn/gom) to build the project and PostgreSQL to make Shorty fly.
```bash
make
# First launch
RESET_DB=1 bin/shorty
# Futher launches
bin/shorty
```
#### Configuration
You can specify DB connection string by setting DB_CONN variable:
```bash
DB_CONN="dbname=my_db sslmode=disable" bin/shorty
```
You can specify server address by setting ADDRESS variable:
```bash
ADDRESS="192.168.1.1:4321" bin/shorty
```
And the hostname that will be used as a base for short links:
```bash
HOSTNAME="shorty.com" bin/shorty
```
## API
````
POST /shorten (url=http://url_to_short.com/?lorem=ipsum)
# => http://domain.com/:code
GET /expand/:code
# => http://url_to_short.com/?lorem=ipsum
GET /:code
# => Redirect to http://url_to_short.com/?lorem=ipsum
GET /statistics/:code
# => Count of redirects to http://url_to_short.com/?lorem=ipsum
````
## How to run tests
First of all you need a public PostgreSQL DB named `shorty_test`.
Next install testing packages with
```bash
gom -test install
```
And finally run the following
```bash
gom test src/*
```