Skip to content

jdaniecki/url-shortener

Repository files navigation

url-shortener

URL shortener design and POC

TODO

Usage

To shorten a URL, send a POST request to the /shorten endpoint with a JSON body containing the URL to be shortened:

curl -X POST http://localhost:8080/shorten \
-H "Content-Type: application/json" \
-d '{"url": "https://example.com"}'

The response will contain the shortened URL:

{
    "shortUrl":"http://localhost:8080/0"
}

To retrieve the original URL, send a GET request to the /{shortUrl} endpoint:

curl http://localhost:8080/0

The response will contain redirect to the original URL.

Develop

Prerequisites

  • go 1.23+ installed. You can install it by following the instructions here.
  • mage installed. You can install it by following the instructions here.
  • oapi-codegen installed. You can install it by following the instructions here.
  • golangci-lint installed. You can install it by following the instructions here.

How to Build

To build the project, run the following command:

mage build

How to Run

To run the project, use:

mage run

How to Test

To execute tests, run:

mage test

About

URL shortener design and POC

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published