URL shortener: Difference between revisions

m
no edit summary
No edit summary
mNo edit summary
Line 1:
{{draft task}}[[Category:Networking and Web Interaction]]
 
The job of a [https://en.wikipedia.org/wiki/URL_shortening URL shortener] is to take a long URL (e.g. "https://www.cockroachlabs.com/docs/stable/build-a-go-app-with-cockroachdb.html") and turn it into something shorter (e.g. "https://bit.ly/2QLUQIu").
Create a simple URL shortener to demonstrate your programming language's web API capabilities with the following endpoints:
 
A simple URL shortener with no special rules is very simple and consists of 2 endpoints:
 
* One to generate a short version of a URL given a long version of a URL.
* One to handle a call to the short version of a URL and redirect the user to the long (original) version of the URL.
<br />
Create a simple URL shortener to demonstrate your programming language's webshortening API capabilities with the following endpoints:
 
'''POST /'''
 
A POST endpoint that accepts a JSON body describing the URL to shorten. Your URL shortener should generate a short version of the URL (like https://bitly.com/),and keep track of the mapping between short and long URLs, and return the short version to the user. For example:
 
$ curl --location --requestX POST 'localhost:30008080' \
-H 'Content-Type: application/json' \
-d '{
"long": "https://googlewww.cockroachlabs.com/docs/stable/build-a-go-app-with-cockroachdb.html"
}'
 
http://localhost:3000/9eXmFnuj
Should returning something similar to:
 
http://localhost:30008080/9eXmFnuj
 
'''GET /:short'''
Line 19 ⟶ 29:
 
$ curl -L http://localhost:3000/9eXmFnuj
 
<!doctype html><html...
Should redirect the user to the original URL:
 
<!doctypeDOCTYPE html><html...
<html lang="en">
...
 
'''Rules''':