URL shortener
URL shortener is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.
Create a simple URL shortener to demonstrate your programming language's web 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/), keep track of the mapping between short and long URLs, and return the short version to the user. For example:
$ curl --location --request POST 'localhost:3000' \ -H 'Content-Type: application/json' \ -d '{ "long": "https://google.com" }' http://localhost:3000/9eXmFnuj
GET /:short
A GET endpoint that accepts a short version of the URL in the URL path and redirects the user to the original URL. For example:
$ curl -L http://localhost:3000/9eXmFnuj <!doctype html><html...
Rules:
- Store the short -> long mappings in any way you like. In-memory is fine.
- There are no auth requirements. Your API can be completely open.