Skip to content

Latest commit

 

History

History
81 lines (51 loc) · 1.93 KB

README.md

File metadata and controls

81 lines (51 loc) · 1.93 KB

thoth Build Status

A simple URL shortner written in clojure and built on top of noir and mongodb.

The URLs are shortened using a base62 strings as ids.

Usage

First go to src/thoth/config.clj and set your environments for production, development and test. Basically you need to provide the following:

  • An url with mongo credentials to use.
  • An auth-token used to validate requests when creating shortened urls.

After this, you need to set an environment variable to the desired environment:

export APP_ENV=development
lein deps
lein run

That should be it! Now your app should be working.

Thoth API instructions.

Creating a shortened url

To shorten an url you must do a post method to the url "/shortify" of your app with the following parameters:

  • auth: Containing the auth-token to validate the request.
  • url: Url to be shortened.

Example with cURL:

 curl -i http://myshort.cl/shortify -F url="www.google.com" -F auth=12345678

The response should be a json like these:

{"shortened_url":"1lQ","url":"http://www.google.com"}

Where shortened_url is the shortened id.

Retrieving an URL.

Then you just need to do a GET request to your shortener with that id and it should redirect to the original url:

 curl -i http://myshort.cl/1lQ

Instructions to deploy to Heroku.

By default, the config file in production enviroment will try to look for a herokuhq environment variable. So setting up the application to heroku should be as simple as (assuming you have heroku alredy configured):

  1. git clone thoth.
  2. cd thoth.
  3. heroku create --stack cedar
  4. git push heroku master
  5. heroku addons:add mongohq:free
  6. heroku config:add APP_ENV=production

License

Copyright (C) 2012 Rafael Chacón

Distributed under the Eclipse Public License, the same as Clojure.