Go to file
Ivan Bushchik d0a78839ca
Add tea.yaml
Signed-off-by: Ivan Bushchik <ivabus@ivabus.dev>
2023-07-01 18:04:20 +03:00
src 0.3.3 2023-06-09 09:01:47 +03:00
.gitignore 0.2.0: Add support for redirecting via html 2023-06-05 09:59:25 +03:00
.rustfmt.toml Initial commit 2023-06-03 17:18:57 +03:00
Cargo.toml 0.3.3 2023-06-09 09:01:47 +03:00
LICENSE Initial commit 2023-06-03 17:18:57 +03:00
README.md 0.3.1: Generate random strings instead of UUIDs in create_alias, if alias is not provided 2023-06-08 09:11:05 +03:00
redirect.html.example 0.2.0: Add support for redirecting via html 2023-06-05 09:59:25 +03:00
Rocket.toml 0.3.1: Generate random strings instead of UUIDs in create_alias, if alias is not provided 2023-06-08 09:11:05 +03:00
tea.yaml Add tea.yaml 2023-07-01 18:04:20 +03:00

aliurl

ALIaser for URLs

Small http service to create aliases for URLs.

Installation

git clone https://github.com/ivabus/aliurl
cd aliurl
cargo b -r

Configuration

Add your access_keys (separating by newline) to ./access_keys or don't add any, if you don't want to use authorization.

Edit Rocket.toml to set port and ip.

Running

cargo run -r

API

Create new alias

Request

POST /api/create_alias HTTP/1.1

Request body

{
    "url": "<URL_TO_BE_ALIASED>",
    "alias": "<ALIAS_URI>",      // If not provided, random string will be generated
    "access_key": "<ACCESS_KEY>" // May not be provided, if no ./access_keys file
    "redirect_with_ad": "<BOOL>" //May not be provided, if provided will use ./redirect.html
}

Get all aliases

Request

POST /api/create_alias HTTP/1.1

Request body

{
    "access_key": "<ACCESS_KEY>" // May not be provided, if no ./access_keys file
}

Response body

[
    {
        "alias": "alias_without_ad",
        "url": "https://example.com"
    },
    {
        "alias": "alias_with_ad",
        "redirect_with_ad": true,
        "url": "https://example.com"
    }
]

Remove alias

Removes all alias with provided name.

Request

POST /api/remove_alias HTTP/1.1

Request body

{
    "alias": "<ALIAS>",
    "access_key": "<ACCESS_KEY>" // May not be provided, if no ./access_keys file
}

Response

Alias(es) removed
[
    {
        "alias": "alias",
        "url": "https://example.com"
    },
    {
        "alias": "alias",
        "redirect_with_ad": true,
        "url": "https://another.com"
    }
]
No aliases found
[]

Use alias

Request

GET /<ALIAS> HTTP/1.1

Response

HTTP/1.1 303 See Other
location: <URL>

Alias for /

Aliases for root is declared in src/main.rs file in INDEX_REDIRECT const.

Redirect with "ad"

See ./redirect.html.example to understand what's going on.

License

The project is licensed under the terms of the MIT license.