Goto is a service designed to shorten URLs.
It is an HTTP API server which stores data in-memory and can optionally persist
it to disk.
2 clients are available for it, a front-end web interface and a CLI tool.
cargo run
# or
cargo build --release
target/release/goto-api
Same thing, but with some options:
cargo run -- --addr 127.0.0.1:8080 --database ./database.yml --frontdir front/dist/
Use cargo run -- --help
for available options and their description.
make build-cli # build for release and move to /usr/local/bin/goto
goto --version
# OR
cargo build --bin goto
target/debug/goto --version
The first time you run the CLI, it will create its configuration at
$HOME/.goto/config.yml
. Feel free to edit it to change the defaults!
# show available options
goto --help
# create a new short URL
goto hello http://world
# browse this url, it will automatically open your web browser
goto hello
# display the URL but don't browse it
goto hello --no-open-browser
rm /usr/local/bin/goto
rm -rf $HOME/.goto
The front-end is designed to be served by the API, so make sure to have the API started and running.
$ cd front/
$ make build
# it is now ready to be served by the API
$ echo http://127.0.0.1:8080/
You can of course host the front-end somewhere else if you want.
You can also directly query the API with any HTTP client.
# create a new shortened URL
$ curl -X POST 127.0.0.1:8080/tsauvajon -d "https://linkedin.com/in/tsauvajon"
/tsauvajon now redirects to https://linkedin.com/in/tsauvajon
# browse it
$ curl 127.0.0.1:8080/tsauvajon
redirecting to https://linkedin.com/in/tsauvajon...