Skip to content

heapwolf/redirector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SYNOPSIS

A simple redirect server / URL shortener.

MOTIVATION

An example of how to use nodeuv-http.

USAGE

./server

HTTP API

SHORTEN

To shorten a urlencoded long url, add a url parameter to the query string with its value encoded.

REQUEST

PUT http://mic.cm/shorten?url=http%3A%2F%2Fmic.com%2Fmy-long-url

RESPONSE

HTTP/1.1 200 OK
Content-Type: plain/text

aZ9yB

REDIRECT

To redirect to long url, look up the url by the provided id and respond with a 301 to the client with the long version of the url.

REQUEST

GET http://mic.cm/aZ9yB

RESPONSE

HTTP/1.1 301 Moved Permanently
Location: http://mic.com/my-long-url

SHORTEN EXISTING

When the /shorten api call is made on an existing url, the url is looked up and if it's already shortened, the existing id is returned.

REQUEST

PUT http://mic.cm/shorten?url=http%3A%2F%2Fmic.com%2Fmy-long-url

RESPONSE

HTTP/1.1 200 OK
Content-Type: plain/text

aZ9yB

About

A simple redirect server / URL shortener in C++ backed by nodeuv-http (libuv and http_parser) and leveldb.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published