go-url-shortener

module
v0.0.0-...-c3818ae Latest Latest
Warning

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

Go to latest
Published: May 18, 2023 License: MIT

README

go-url-shortener

simple url shortener written in Go.

Installation

  1. Clone the repository.
git clone https://github.com/fidesy/go-url-shortener.git
cd go-url-shortener
  1. Rename .env.example to .env
cp .env.example .env
  1. Select preferable database in ./configs/config.yaml field database options: postgres, mongo

  2. Run app.

docker compose up -d

Usage

Sign up

curl -X POST -d '{"name": "John", "username": "john", "password": "john"}' http://localhost:8000/auth/sign-up

# {"id": 1}

Sign in and get authorization token

curl -X POST -d '{"username": "john", "password": "john"}' http://localhost:8000/auth/sign-in

# {"token": "YOUR_TOKEN"}

Create short URL

curl -X POST -H "Authorization: Bearer <YOUR_TOKEN>" -d '{"original_url": "https://vk.com"}' "http://localhost:8000/create"

# {"short_url": "http://localhost:8000/ti2SMt"}

Get original URL and Redirect

curl http://localhost:8000/ti2SMt

# <a href="https://vk.com">Temporary Redirect</a>.

Directories

Path Synopsis
cmd
internal
pkg

Jump to

Keyboard shortcuts

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