A url shortener written in Go with SQLite3 that provides a RESTful API to allow users to easily interact with it.
Typically a shortened url will have an N character hash appended to the hosting domain and this link will simply redirect to the correct page.
e.g. t02smith.com may be allocated link.t02smith.com/56735
First clone the repository:
git clone https://github.com/t02smith/url-shortener.git
Then to run you can either:
-
Run locally:
go run main.go
-
Run on a Docker container:
docker-compose up --build
Constants within the application can be changed to suit your needs. Currently included constants are:
- DATABASE_LOCATION = path to SQLite3 database
- DOMAIN = Domain the application is being hosted on
- HASH_SIZE = The length of the hash for the shortened URL
- API_PATH = The prefix to API call paths
- PORT = The port to listen on = NOTE: should match port in Dockerfile & docker-compose.yml
path: /newURL
content: {
url: string, // the url you want to shorten
request: string, // request a mapping
}
shortened urls should have time limits e.g. by dayrequest field in the get request to ask for a specific URL- Webpages:
enter URL and receive shortened copyAdd requested URL field
- error pages (redirect, timeout error)
- Unit testing
Serve static folder- Update response to include metadata