Skip to content

Ghostofpq/bigzelda

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bigzelda

BigZelda is a shortlink creator (because short link ᕕ( ᐛ )ᕗ)

Features

A shortlink is the association of a base URL (origin) and a more simple key (token) randomly generated or given by the user. BigZelda offers via a REST API a shortlink service to register shortlinks, use shortlinks and inspect shortlinks (to get the number of time it has been used). These shortlinks are stored in a Redis.

Conf

There is a configuration file in the conf directory. With this configuration file, you can change

  • the port on wich the BigZelda application API is exposed
  • the token max size
  • the shortlink Time To Live (Duration in seconds before redis removes an unused shortlink)
  • the redis connections details and credentials (you only need to set them if you are running the application as a go app and not packaged in docker)
  • the logfile name (final logfile name are : filenameYYYYMMDD.log)
  • the log level (DEBUG/INFO/WARN/ERROR)

Run

with Docker

Go in the BigZelda directory and use ./install.sh and ./start.sh

This should run in your docker 2 containers

  • redis : a simple redis-server
  • bigzelda : the bigzelda go application

Api

BigZelda exposes a simple API on the port 80. To change this port, modify the command line in start.sh (... --publish 80:8000 ... )

This API is accessible on localhost (:80) (if you are on windows and use docker-toolbox, use the command >docker-machine ls to get the URL of you VM)

Method GET
URL /shortlink/my.simpleURL.com where my.simpleURL.com is the URL you want to get a shortlink for
param custom (optional) value under wich you want to save this URL
returns a Json structure containing the token and the origin
example /shortlink/www.google.com?custom=g {"Origin":"http://www.google.com","Shortlink":"http://localhost/g"}

Since encoding a URL to create a shortlink would break the simplicity, for "complex" URL to encode (like https://github.com/tools/godep), please use the following POST method

Method POST
URL /shortlink
body a origin-token tuple where origin is the target of the link and token the value under wich you want to save this URL
returns a Json structure containing the token and the origin
example /shortlink body={"origin":"https://github.com/tools/godep","token":"godep"} {"Origin":"https://github.com/tools/godepII","Shortlink":"http://localhost/godep"}
Method GET
URL /shtlnk where shtlnk is the shortlink token
returns nothing, you are redirected to the target
example /g you are now on http://www.google.com
Method GET
URL /admin/shtlnk where shtlnk is the shortlink token
returns the Shortlink object stored in redis
example /admin/shtlnk {"Id":"7e3b6d7d-dbeb-44ba-839b-80442accef55","Token":"g","Origin":"http://www.google.com","CreationTs":1447263537,"Count":1}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published