Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/heapwolf/redirector
A simple redirect server / URL shortener in C++ backed by nodeuv-http (libuv and http_parser) and leveldb.
https://github.com/heapwolf/redirector
Last synced: 25 days ago
JSON representation
A simple redirect server / URL shortener in C++ backed by nodeuv-http (libuv and http_parser) and leveldb.
- Host: GitHub
- URL: https://github.com/heapwolf/redirector
- Owner: heapwolf
- Created: 2014-09-13T20:18:38.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2014-09-18T14:04:01.000Z (about 10 years ago)
- Last Synced: 2024-10-03T08:33:18.654Z (about 1 month ago)
- Language: C++
- Homepage:
- Size: 144 KB
- Stars: 12
- Watchers: 6
- Forks: 3
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# SYNOPSIS
A simple redirect server / URL shortener.# MOTIVATION
An example of how to use [`nodeuv-http`](https://github.com/hij1nx/nodeuv-http).# USAGE
```bash
./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/textaZ9yB
```## 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/textaZ9yB
```