forked from fs111/kurz.go
a url shortener made using web.go and redis
License
vormplus/kurz.go
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
__ | |--.--.--.----.-----. .-----.-----. | <| | | _|-- __|__| _ | _ | |__|__|_____|__| |_____|__|___ |_____| |_____| by @fs111 kurz.go - a url shortener in go -------------------------------- kurz.go is my attempt to write a program that is actually useful in go. Right now it is in alpha stage, but will eventually grow into a the real thing. Right now it can shorten URLs, redirect and list the latest stored URLs. All urls are stored in a redis (http://redis.io) instance. Compiling kurz.go ----------------- Next to having a full install of go itself, kurz.go requires web.go and godis to be installed. For installing go itself, please follow the fine instructions at http://golang.org For installing web.go do: $ git clone https://github.com/hoisie/web.go.git $ cd web.go $ make install (should work against the latest weekly release) for isntalling godis do: $ git clone https://github.com/simonz05/godis.git $ cd godis $ make install Note: These modules will be installed into your $GOROOT, so make sure it is writable. Once the dependecies are installed, check out kurz.go: $ git https://github.com/fs111/kurz.go $ make $ ./kurz conf/kurz.conf #assumes that redis is up and running In order to shorten a url POST it to http://localhost:9999/shorten/ with the parameter url set to the long url. In return, you will get a json document containing the long and the short url. If you open the shortened URL, "kurz" will do the expected thing an redirect you to the original URL. All functionality is shown below: # store a URL $ curl http://localhost:9999/shorten/ --data-urlencode "url=https://github.com/fs111/kurz.go" {"Key":"eIi","ShortUrl":"http://localhost:9999/eIi","LongUrl":"http://github.com/fs111/kurz.go","CreationDate":1321486517214982000,"Clicks":0} # open a URL $ curl http://localhost:9999/eIi Redirecting to: http://github.com/fs111/kurz.go # show information about a url $ curl http://localhost:9999/eIi+ # notice the bit.ly style + in the end {"Key":"eIi","ShortUrl":"http://localhost:9999/eIi","LongUrl":"http://github.com/fs111/kurz.go","CreationDate":1321486517214982000,"Clicks":1} # list latest URLs $ curl http://localhost:9999/latest/1 { "urls" : [{"Key":"eIi","ShortUrl":"http://localhost:9999/eIi","LongUrl":"http://github.com/fs111/kurz.go","CreationDate":1321486517214982000,"Clicks":0}] } All urls are stored in redis and if you set it up so, that it persists data to disk, the state can be kept forever. Since there is no real state within kurz.go, you could run multiple instances of it, but I have not tried it yet. Testing it out -------------- The 'stuff' directory contains a shell-script that imports the csv file into kurz.go. Just try it out! Note: The csv file might contain some NSFW urls, I found it on the interwebs somewhere. You have been warned. Have fun with it! -- @fs111
About
a url shortener made using web.go and redis
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published
Languages
- Go 76.1%
- JavaScript 22.5%
- Shell 1.4%