Prince-1501/url-shortner ? reverse-engineered prompt
Reverse engineered prompt
Build me a simple URL shortener in Go that I can run locally.
I want a small web server that listens on port 8080, accepts a POST request to /shorten with a JSON body like { "url": "https://example.com" }, and returns a short URL in JSON. Then when I open the short link or call /redirect/{id}, it should send me to the original long URL.
Keep it simple and easy to understand, since this is just a basic demo app. If it helps, use an in memory store for the URL mappings and make the code clean with a straightforward main.go. Please include a few example requests in the README and make sure it runs with go run main.go. If you need to check anything current, look up the latest Go docs online.