2023-06-03 17:18:57 +03:00
|
|
|
# aliurl
|
|
|
|
|
|
|
|
> ALIaser for URLs
|
|
|
|
|
|
|
|
Small http service to create aliases for URLs.
|
|
|
|
|
|
|
|
## Installation
|
|
|
|
|
|
|
|
```shell
|
|
|
|
git clone https://github.com/ivabus/aliurl
|
|
|
|
cd aliurl
|
|
|
|
cargo b -r
|
|
|
|
```
|
|
|
|
|
|
|
|
### Configuration
|
|
|
|
|
2023-06-05 09:59:25 +03:00
|
|
|
Add your access_keys (separating by newline) to `./access_keys` or don't add any, if you don't want to use authorization.
|
2023-06-03 17:18:57 +03:00
|
|
|
|
|
|
|
Edit `Rocket.toml` to set port and ip.
|
|
|
|
|
|
|
|
### Running
|
|
|
|
|
|
|
|
```shell
|
|
|
|
cargo run -r
|
|
|
|
```
|
|
|
|
|
2023-06-05 12:04:27 +03:00
|
|
|
## API
|
2023-06-03 17:18:57 +03:00
|
|
|
|
|
|
|
### Create new alias
|
|
|
|
|
|
|
|
#### Request
|
|
|
|
|
|
|
|
```http request
|
2023-06-05 12:04:27 +03:00
|
|
|
POST /api/create_alias HTTP/1.1
|
2023-06-03 17:18:57 +03:00
|
|
|
```
|
|
|
|
|
|
|
|
#### Request body
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"url": "<URL_TO_BE_ALIASED>",
|
2023-06-08 09:11:05 +03:00
|
|
|
"alias": "<ALIAS_URI>", // If not provided, random string will be generated
|
2023-06-03 17:18:57 +03:00
|
|
|
"access_key": "<ACCESS_KEY>" // May not be provided, if no ./access_keys file
|
2023-06-05 09:59:25 +03:00
|
|
|
"redirect_with_ad": "<BOOL>" //May not be provided, if provided will use ./redirect.html
|
2023-06-03 17:18:57 +03:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2023-06-05 12:04:27 +03:00
|
|
|
### Get all aliases
|
|
|
|
|
|
|
|
#### Request
|
|
|
|
|
|
|
|
```http request
|
|
|
|
POST /api/create_alias HTTP/1.1
|
|
|
|
```
|
|
|
|
|
|
|
|
#### Request body
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"access_key": "<ACCESS_KEY>" // May not be provided, if no ./access_keys file
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
#### Response body
|
|
|
|
|
|
|
|
```json
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"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
|
2023-06-03 17:18:57 +03:00
|
|
|
|
2023-06-05 12:04:27 +03:00
|
|
|
```http request
|
|
|
|
POST /api/remove_alias HTTP/1.1
|
|
|
|
```
|
|
|
|
|
|
|
|
#### Request body
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"alias": "<ALIAS>",
|
|
|
|
"access_key": "<ACCESS_KEY>" // May not be provided, if no ./access_keys file
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
#### Response
|
|
|
|
|
|
|
|
##### Alias(es) removed
|
|
|
|
|
|
|
|
```json
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"alias": "alias",
|
|
|
|
"url": "https://example.com"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"alias": "alias",
|
|
|
|
"redirect_with_ad": true,
|
|
|
|
"url": "https://another.com"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
```
|
|
|
|
|
|
|
|
##### No aliases found
|
|
|
|
|
|
|
|
```json
|
|
|
|
[]
|
|
|
|
```
|
|
|
|
|
|
|
|
### Use alias
|
2023-06-05 09:59:25 +03:00
|
|
|
|
|
|
|
#### Request
|
|
|
|
|
2023-06-03 17:18:57 +03:00
|
|
|
```http request
|
|
|
|
GET /<ALIAS> HTTP/1.1
|
|
|
|
```
|
2023-06-05 09:59:25 +03:00
|
|
|
#### Response
|
2023-06-03 17:18:57 +03:00
|
|
|
|
|
|
|
```http request
|
|
|
|
HTTP/1.1 303 See Other
|
|
|
|
location: <URL>
|
|
|
|
```
|
|
|
|
|
|
|
|
### Alias for `/`
|
|
|
|
|
|
|
|
Aliases for root is declared in `src/main.rs` file in `INDEX_REDIRECT` const.
|
|
|
|
|
2023-06-05 09:59:25 +03:00
|
|
|
## Redirect with "ad"
|
|
|
|
|
|
|
|
See `./redirect.html.example` to understand what's going on.
|
|
|
|
|
2023-06-03 17:18:57 +03:00
|
|
|
## License
|
|
|
|
|
|
|
|
The project is licensed under the terms of the [MIT license](./LICENSE).
|