Run and test your FastEdge applications locally with the Gcore FastEdge CLI tool. The following instructions will help you install, build, and execute some basic commands with FastEdge CLI.
We are actively developing FastEdge CLI and recommend regularly checking the FastEdge-lib repository for updates and new versions.
1. Clone the FastEdge-lib repository.
2. Install Rust by running the following command:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh source "$HOME/.cargo/env"
3. In the directory where you cloned the repository, run the following command to initialize and update all submodules: git submodule update --init --recursive -f
4. Build the CLI tool and all required dependencies: cargo build –release
5. Compile and run the binary with the help
flag to view the full list of available CLI commands and parameters: cargo run --bin cli -- --help
To run the compiled CLI tool, use the following command:
./target/release/cli [command]
For example, if you want to open help and view the list of supported commands, run: ./target/release/cli http --help
.
This section provides some basic examples of how to work with FastEdge CLI. The sample commands use a test application from the FastEdge-examples repository.
Execute the following command:
./target/release/cli http –w [path-to-your-application] –-port [port number]
For example: ./target/release/cli http -w ../FastEdge-examples/rust/target/wasm32-wasi/release/print.wasm –-port 8080
To view the list of all printed headers, run curl http://localhost:8080
Execute the following command:
./target/release/cli http –w [path-to-your-application] –-env [variables] --port [port number]
For example, to set the BASE variable to the URL of the repository’s README:
./target/release/cli http -w ../FastEdge-examples/rust/target/wasm32-wasi/release/markdown.wasm env BASE=https://raw.githubusercontent.com/G-Core/FastEdge-lib/main --port 8080
After executing the command, you can run the FastEdge application, which will output the contents of the README: http://localhost:8080/README.md
FastEdge CLI can add sample geo headers to your application without using a real IP address:
./target/release/cli http -w [path-to-your-application] –geo –port [port number]
For example: ./target/release/cli http -w ../FastEdge-examples/rust/target/wasm32-wasi/release/print.wasm –-geo --port 8081
To view the list of sample geo headers, run curl http://localhost:8081
. You should see an output similar to the following:
Headers:
host: localhost:8081
user-agent: curl/8.6.0
accept: */*
pop-country-name: luxembourg
pop-city: luxembourg
pop-country-code: au
server_name: test.localhost
pop-continent: eu
pop-lat: 49.6113
pop-long: 6.1294
pop-reg: lu%
Was this article helpful?