An open API service indexing awesome lists of open source software.

https://github.com/darthsim/shorty

Tiny url shortener
https://github.com/darthsim/shorty

Last synced: 11 months ago
JSON representation

Tiny url shortener

Awesome Lists containing this project

README

          

# Shorty
[![Build Status](https://travis-ci.org/DarthSim/shorty.svg)](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/*
```