Skip to content

Latest commit

 

History

History
75 lines (55 loc) · 2.13 KB

README.md

File metadata and controls

75 lines (55 loc) · 2.13 KB

URL Shortener

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

Go Badge SQLite Badge Docker Badge Raspberry Pi Badge HTML5 Badge CSS3 Badge

How to Run

First clone the repository:

git clone https://github.com/t02smith/url-shortener.git

Then to run you can either:

  1. Run locally:

    go run main.go
  2. Run on a Docker container:

    docker-compose up --build

Config

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

API

getURL

path: /newURL
content: {
    url: string,     // the url you want to shorten
    request: string, // request a mapping
}

TODO

  • shortened urls should have time limits e.g. by day
  • request field in the get request to ask for a specific URL
  • Webpages:
    • enter URL and receive shortened copy
      • Add requested URL field
    • error pages (redirect, timeout error)
  • Unit testing
  • Serve static folder
  • Update response to include metadata