Tiny url shortener
You will need Go and Gom to build the project and PostgreSQL to make Shorty fly.
make
cp shorty.conf.sample shorty.conf
# First launch
RESET_DB=1 bin/shorty
# Futher launches
bin/shorty
You can specify DB connection string by setting DB_CONN variable:
DB_CONN="dbname=my_db sslmode=disable" bin/shorty
You can specify server address by setting ADDRESS variable:
ADDRESS="192.168.1.1:4321" bin/shorty
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
-
First of all you need a public PostgreSQL DB named
shorty_test
. -
Next install testing packages with
gom -test install
- And finally run the following
gom test src/*