mirror of
https://github.com/minoplhy/chhoto-url.git
synced 2024-11-22 09:16:46 +00:00
docs: Added CLI usage instructions
This commit is contained in:
parent
d48b664c0a
commit
a9168e3459
32
README.md
32
README.md
@ -122,6 +122,38 @@ default, the auto-generated links are adjective-name pairs. You can use UIDs by
|
|||||||
the `slug_style` variable to `UID`. You can also set the length of those slug by setting
|
the `slug_style` variable to `UID`. You can also set the length of those slug by setting
|
||||||
the `slug_length` variable. It defaults to 8, and a minimum of 4 is supported.
|
the `slug_length` variable. It defaults to 8, and a minimum of 4 is supported.
|
||||||
|
|
||||||
|
## CLI usage instructions
|
||||||
|
The application can be used from the terminal using something like `curl`. In all the examples
|
||||||
|
below, replace `http://localhost:4567` with where your instance of `chhoto-url` is accessible.
|
||||||
|
|
||||||
|
If you have set up
|
||||||
|
a password, first do the following to get an authentication cookie and store it in a file.
|
||||||
|
```bash
|
||||||
|
curl -X post -d "<your-password>" -c cookie.txt http://localhost:4567/api/login
|
||||||
|
```
|
||||||
|
You should receive "Correct password!" in case the provided password was correct. For any other
|
||||||
|
request, please add `-b cookie.txt` to use this authentication cookie.
|
||||||
|
|
||||||
|
To add a link, do
|
||||||
|
```bash
|
||||||
|
curl -X POST -d '{"shhortlink":"<shortlink>", "longlink":<longlink>}' http://localhost:4567/api/new
|
||||||
|
```
|
||||||
|
Send an empty `<shortlink>` if you want it to be auto-generated. The server will reply with the generated shortlink.
|
||||||
|
|
||||||
|
To get a list of all the currently available links as `json`, do
|
||||||
|
```bash
|
||||||
|
curl http://localhost:4567/api/all
|
||||||
|
```
|
||||||
|
|
||||||
|
To delete a link, do
|
||||||
|
```bash
|
||||||
|
curl -X DELETE http://localhost:4567/api/del/<shortlink>
|
||||||
|
```
|
||||||
|
The server will send a confirmation.
|
||||||
|
|
||||||
|
You can get the version of `chhoto-url` the server is running using `curl http://localhost:4567/api/version` and
|
||||||
|
get the siteurl using `curl http://localhost:4567/api/siteurl`.
|
||||||
|
|
||||||
## Disable authentication
|
## Disable authentication
|
||||||
If you do not define a password environment variable when starting the docker image, authentication
|
If you do not define a password environment variable when starting the docker image, authentication
|
||||||
will be disabled.
|
will be disabled.
|
||||||
|
Loading…
Reference in New Issue
Block a user