README
¶
Sho: Serverless URL Shortener
sho is a basic url shortener written in Go. Sho is a small API developed for those who want to shorten links to be used in business. It aims to shorten urls and redirecting requests that coming to the urls. No any additional feature. That's all.
Contributions and bug reports are welcome.
Stack
- PostgreSQL
- Golang
- Redis
Endpoints
Short a URL
Request:
POST /
Try it via https://ts7p7oopf5.execute-api.us-east-2.amazonaws.com/dev
{
"target: "https://beratnakip.com"
}
Response:
{
"ID": 12,
"CreatedAt": "2021-08-07T20:02:25.494307616+03:00",
"UpdatedAt": "2021-08-07T20:02:25.494307616+03:00",
"DeletedAt": null,
"target": "http://beratnakip.com",
"address": "BpLnfg"
}
Redirect
GET /{id}
Try it via https://ts7p7oopf5.execute-api.us-east-2.amazonaws.com/dev/3qNfHK
http://localhost:8010/9F3qNf
Development Requirements
- AWS CLI already configured with Administrator permission
- Docker installed
- Golang
- SAM CLI - Install the SAM CLI
Setup process
Installing dependencies & building the target
In this example we use the built-in sam build
to automatically download all the dependencies and package our build target.
Read more about SAM Build here
The sam build
command is wrapped inside of the Makefile
. To execute this simply run
make
Local development
Invoking function locally through local API Gateway
sam local start-api --env-vars env.json
If the previous command ran successfully you should now be able to hit the following local endpoint to invoke your function http://localhost:3000
SAM CLI is used to emulate both Lambda and API Gateway locally and uses our template.yaml
to understand how to bootstrap this environment (runtime, where the source code is, etc.) - The following excerpt is what the CLI will read in order to initialize an API and its routes:
TODO
- URL Statistics
- Url Expire
LICENSE
sho
is released under ¨the Apache License 2.0