Sign inSign up

cjdenio/shorty

By cjdenio

•Updated over 3 years ago

Image
0

1.6K

cjdenio/shorty repository overview

⁠shorty

High-performance link shortener written in Rust

ā šŸ’¾ Hosting

In addition to being easy to build from source, shorty is available as a Docker image on Docker Hub⁠.

ā šŸ Prerequisites
ā šŸŒŽ Environment variables
  • DB_URL - a valid Redis URL, e.g. redis://localhost:1234
  • TOKEN - your desired API token; only required if you're using the API (described below).
ā āš™ļø Server configuration

Configure the server through environment variables or Rocket.toml; check this guide⁠ for more information. shorty runs on port 8000 by default.

ā šŸ“” API

Use shorty's API to add/remove links.

⁠Authentication

Provide your TOKEN (described above) as a bearer token, so set the Authorization header to Bearer <token>. Example: curl -H "Authorization: Bearer token1234" http://localhost:8000/api/example/route

⁠Requests

POST requests must all contain JSON payloads. x-www-form-urlencoded is not supported.

⁠Responses

All responses are JSON, and follow this rough schema:

{
  // False if something went wrong
  "ok": true,

  // Will be a string if something went wrong
  "err": null,

  "data": {
    // Response data here...
  }
}

ā āž• POST /api/link - create or update a named link

Options:

  • url (string, required) - The URL the redirect to.
  • name (string, optional) - The link's name. Leave blank to randomly generate a 10-character ID.
  • public (bool, optional) - Whether or not to display this link on the public links page; coming soon

ā„¹ļø Note: / is a special value for <name> that creates a redirect for the root URL.


example: curl -X DELETE http://localhost:8000/api/link/gh

ā„¹ļø Note: Please URL encode the <name> parameter if necessary; / will become %2F


ā šŸš— Roadmap

  • UI
  • Redirect code configuration

Tag summary

Content type

Image

Digest

sha256:6d7059f1f…

Size

69.9 MB

Last updated

over 3 years ago

docker pull cjdenio/shorty