a url shortener made using go and redis

Overview
 __                                    
|  |--.--.--.----.-----.  .-----.-----.
|    <|  |  |   _|-- __|__|  _  |  _  |
|__|__|_____|__| |_____|__|___  |_____|
                          |_____| 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 beta stage.

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 gorilla.mux,
godis and simpleconfig to be installed. For installing go itself, please follow the fine
instructions at http://golang.org

For installing gorilla/mux do:

    $ go get github.com/gorilla/mux

for installing godis do:

    $ go get github.com/simonz05/godis/redis

for installing simpleconfig do:

    $ go get github.com/fs111/simpleconfig

Note: These modules will be installed into your $GOROOT, so make sure it is
writable. Alternatively you can set $GOPATH and they will be installed there instead.

Once the dependecies are installed, check out kurz.go:
    $ git clone https://github.com/fs111/kurz.go
    $ cd kurz.go
    $ make
    $ cd target
    $ usr/bin/kurz etc/kurz/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 -L 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 -L 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.

UI
--
The amazing @vormplus made a great looking frontend for kurz.go, which you can
see, if you visit http://localhost:9999/index.htm. If you want to reload the
latest urls on that page, just press "." and the table will be refreshed.


Testing it out
--------------
The 'stuff' directory contains a shell-script that imports a 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
You might also like...
Cfurlshort - Url Shortener service with golang

Url Shortener This respository contains the code for my url shortener service. D

Goshort - Just another simple url shortener to use with curl

qnd.be Just another simple url shortener to use with curl. Kinda like 0x0.st. Ju

OMUS - One More URL Shortener

OMUS OMUS - One More URL Shortener; For now - planned only API. Functions: Gener

Short url backend - Go musthave shortener tpl

go-musthave-shortener-tpl Шаблон репозитория для практического трека «Go в веб-р

The 'Scalable' URL shortener

Chinnaswamy The 'Scalable' URL shortener Running tests To run end to end tests: CHINNASWAMY_TEST_HOST="host:port" go test -count=1 ./integration_tes

The source code for workshop Scalable architecture using Redis as backend database using Golang + Redis

The source code for workshop Scalable architecture using Redis as backend database using Golang + Redis

Implementing URL shortening with Go and Redis as cache with Rate Limiting

URL-Redis Implementing URL shortening with Go and Redis as cache with Rate Limiting. In this project I have tried to implement on of daily task used i

urlhunter is a recon tool that allows searching on URLs that are exposed via shortener services such as bit.ly and goo.gl.
urlhunter is a recon tool that allows searching on URLs that are exposed via shortener services such as bit.ly and goo.gl.

a recon tool that allows searching on URLs that are exposed via shortener services

A simple demo written in Golang to shorten URL and redirect

url-shortener A simple demo written in Golang to shorten URL and redirect . ├── go.mod ├── go.sum ├── handler │ └── handlers.go ├── main.go ├── shor

Comments
  • Introduce logging

    Introduce logging

    Interested in this project for personal use (mostly learning). Decided to add some logging to see what's possible. Felt a little bit difficult to understand things without any output.

    opened by dimitrismistriotis 3
  • redis.addres should be redis.netaddres

    redis.addres should be redis.netaddres

    kurl.go Line: 207 host := config.GetStringDefault("redis.address", "tcp:localhost:6379")

    should be like host := config.GetStringDefault("redis.netaddress", "tcp:localhost:6379")

    opened by zheng-ji 1
Owner
André Kelpe
André Kelpe
A URL shortener using http://is.gd/ and the Go programming language (http://golang.org/)

goisgd A simple command line URL shortener using http://is.gd/. Getting the Code go get github.com/NickPresta/GoURLShortener Usage Import this librar

Nick Presta 22 Apr 6, 2022
A barebones URL Shortener implementation in Go using Gin and MySQL. Also features a basic frontend.

URL Shortener in Go This is a barebones URL Shortener implementation in Go using the Gin web framework and MySQL. Also features a basic frontend. Loca

Shreyas Gupta 6 Dec 22, 2021
urlsh is URL shortener application built on Go language.

GOlang URL shortener service with UI, API, Cache, Hits Counter and forwarder using postgres and redis in backend, bulma in frontend

Jitendra Adhikari 125 Dec 11, 2022
Go URL shortener

Golang Short URL To build the short link engine by Go. Development Environment: Ubuntu 20.04 Go 1.17.1 Requirement Console app, receive “URL” from any

Siong-Ui Te (戴上為) 0 Nov 4, 2021
A simple URL shortener application.

url-shortener A simple URL shortener application. Features The service supports 2 data stores (in-memory and PostgreSQL). The -db parameter is used to

Demid Fedorov 0 Dec 9, 2021
Yandex practicum go url shortener service

go-musthave-shortener-tpl Шаблон репозитория для практического трека «Go в веб-р

Dindon 0 Feb 26, 2022
Url Shortener Api For Golang

Url Shortener Api Using Go Endpoints Get and redirect to long url GET: "/:id" Cr

Lutfi Andriyanto 1 May 29, 2022
Simple URL shortener written in Golang

Alviss Introduction Simple URL shortener project, written in Golang. Setup and r

Amir Iravanimanesh 22 Aug 25, 2022
A sample url shortener app to test Keploy integration capabilities

Example URL Shortener A sample url shortener app to test Keploy integration capabilities Installation git clone https://github.com/keploy/example-url-

null 6 Oct 22, 2022
API from AnonURL website, an anonymous URL shortener

API from AnonURL website, an anonymous URL shortener

null 0 Jan 23, 2022