Shorts Ninja 🥷 ⚔️
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