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.
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:
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:
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):
- git clone thoth.
- cd thoth.
- heroku create --stack cedar
- git push heroku master
- heroku addons:add mongohq:free
- heroku config:add APP_ENV=production
Copyright (C) 2012 Rafael Chacón
Distributed under the Eclipse Public License, the same as Clojure.