shurl

command module
v0.0.0-...-af1bce4 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2024 License: MIT Imports: 6 Imported by: 0

README

logo

What is shurl?

"shurl" is an elegant backend solution for a customizable URL shortener application. It allows users to generate shortened URLs while providing the option to customize the endpoint, specify its length, and set an expiry time. The application is written in GO and utilizes Redis as a database.

Showcase

Make a shurl to "exampl.com"

// POST "localhost:3000"
{ 
    "url": "example.com" 
}

// Response
{
    "url": "http://example.com",
    "shurl": "localhost:3000/xQ9DC",
    "length": 5,
    "expiry": 0
}

Set custom endpoint

// POST "localhost:3000"
{
    "url": "example.com",
    "shurl": "example"
}

// Response
{
    "url": "http://example.com",
    "shurl": "localhost:3000/example",
    "length": 7,
    "expiry": 0
}

Specifie length of endpoint and set expiry time (in hours)

// POST "localhost:3000"
{
    "url": "example.com",
    "length": 8,
    "expiry": 24
}

// Response
{
    "url": "http://example.com",
    "shurl": "localhost:3000/FpQpLdFN",
    "length": 8,
    "expiry": 24
}

Visiting localhost:3000/xQ9DC, localhost:3000/example or localhost:3000/FpQpLdFN will redirect to exmaple.com

Installation

To build "shurl" and launch server, follow these steps:

  1. Clone and build "shurl":
git clone github.com/axseem/shurl
cd shurl
go build
  1. Set environment variables in ".env" file:
DB_ADDR="localhost:6379"
DB_PASS=""
PORT=":3000"
DOMAIN="localhost${PORT}"
  1. Execute the built application to launch the server:
./shurl

Usage

Here are some enpoints end its methods:

  • / POST <shurl> - Create a shurl
  • /:id GET - Redirect to full URL

License

This project is licensed under the MIT License.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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