shortsninja

command module
v0.0.32-0...-5ee999a Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2021 License: GPL-2.0, GPL-3.0 Imports: 7 Imported by: 0

README

Shorts Ninja 🥷 ⚔️

GoDoc Go Report Card GitHub

Shorts Ninja is a simple URL shortener written in Go.


Usage 🛠️

Website 💻

Use the web for full functionality!

  • Visit shorts.ninja
  • Enter your long URL
  • optional type a wanted short handler
  • Enjoy you little URL :)


API 🧐

The only endpoint that are usable outside the website are /shorten/ and /{short_url}

GET /shorten/?url=some_long_url&short=custom_handler

Create a short URL from a given url with an optional custom handler

eg : curl -XGET https://shorts.ninja/shorten/?url=https://github.com

The response body looks like this when every thing is ok

{
    "short": "shorts.ninja/JzaW9",
    "url": "https://github.com",
    "valid_url": true
}

if the provided URL is invalid, or it's not http, https or ftp the response looks like this

eg: curl -XGET https://shorts.ninja/shorten/?url=not.valid.url

{
    "valid_url": false
}

Also, when providing a custom short handler, another response attribute is added ie short_exists to indicate whether the custom short URL exist or not!

eg: curl -XGET https://shorts.ninja/shorten/?url=https://github.com&short=hello

{
    "short": "shorts.ninja/hello",
    "short_exists": false,
    "url": "https://github.com",
    "valid_url": true
}

If the previous URL is called again, the response will have the short URL alongside short_exists = true

{
    "short": "shorts.ninja/hello",
    "short_exists": true,
    "url": "https://github.com",
    "valid_url": true
}

GET /{short_url}

Opens a URL using its short handler if exists 😉, otherwise it rickrolls the caller so be careful using it!

eg: curl -XGET https://shorts.ninja/JzaW9

the response body is just an HTML with the target URL so when opened in the browser it automatically goes to the URL

<a href="https://github.com">Found</a>

Dependencies 📚


Run Locally 🖥️

  • Clone the repo
  • Change admin password in config.json
  • optional add your google cloud api and ipinfo.io tokens
  • Compile and run
  • Enjoy

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