urlShortener

module
v0.0.0-...-c8ee330 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 29, 2023 License: MIT

README

Short url generator

Lines of code License Go version Last commit

This is simple project for understanding how work with postgresql, docker in golang. It generates for an url a short url or uses the custom short url sent in the request.

REST API

Method POST

This method creates new short url.

  • path: api/v1/create/
  • body:
{
    "url":"https://example.com",
    "short_url":"example"
}

if you need to generate a short url - sent only the url

  • return body:
{
  "message": "http://localhost:8080/example"
}
  • code: 200
Method GET

This method redirects to the original url or returns all short url information.

  • redirect:
    • path: short_url
    • code: 301
  • short url info:
    • path: api/v1/short_url
    • return body:
{
  "short_url": "example",
  "origin_url": "https://example.com",
  "visits": 1,
  "date_created": "2023-01-29T17:33:42.901111Z",
  "date_updated": "2023-01-29T19:22:15.431546Z"
}
  • code: 200
Method DELETE

This method delete short url info from database.

  • path: api/v1/delete/short_url
  • code: 204

Usage

#build docker image
make build

#run the application
make run

#test application into container
make test

#stop the application
make stop

Directories

Path Synopsis
cmd
api
internal
pkg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL