Anonymous user
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
'''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
$ curl -
-H 'Content-Type: application/json' \
-d '{
"long": "https://
}'
http://localhost:3000/9eXmFnuj▼
Should returning something similar to:
'''GET /:short'''
Line 19 ⟶ 29:
$ curl -L http://localhost:3000/9eXmFnuj
<!doctype html><html...▼
Should redirect the user to the original URL:
<html lang="en">
...
'''Rules''':
|