/go-url-short

implementing a simple short url website in go

Primary LanguageGo

go-url-short

This is a simple url shortener written in golang. It uses pulumi to deploy to AWS Lambda with API Gateway.

Pre-requisite

Feature

  • Support for multiple database storage options (in-memory, PostgreSQL).
  • Deploy to AWS Lambda using Pulumi
  • Integration of custom domains via ACM.
  • Encode IDs using a base-62
  • Rest API Format
  • Using Snowflake ID Generator (Epoch + NodeID + Sequence)
    • Epoch is 2023-10-29 00:00:00`

TODO

  • Add e2e tests
  • Add Frontend Web UI

How to use it

Demo

Deployed to AWS Lambda with API Gateway.

Generate Short URL

curl -X POST https://s.m0ai.dev/shorten\?url\=https://google.com | jq 
  
> {
>   "short_url": "https://s.m0ai.dev/AaecfgMo",
>   "url": "https://google.com"
> }

Get Short URL

curl -X GET https://s.m0ai.dev/AaecfgMo

> HTTP/1.1 308 Permanent Redirect
> Content-Type: text/html; charset=utf-8
> Location: https://google.com
> Date: Sun, 29 Oct 2023 08:26:53 GMT

How to deploy it (aws only)

# clone the repo
make deploy

# if you want to deploy to your own domain
# Domain and ACM is required
DOMAIN=yourdomain.com make deploy