mirror of
https://github.com/dathere/ckanaction.git
synced 2026-05-20 01:44:16 +00:00
chore: examples update and docs, add package-list example
This commit is contained in:
parent
4ff1155d9b
commit
a88a8fffc3
8 changed files with 2299 additions and 275 deletions
|
|
@ -90,3 +90,12 @@ To run some of the tests in the `tests` directory, first replace the values for
|
||||||
```bash
|
```bash
|
||||||
cargo test
|
cargo test
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
You can run an example from the `examples` directory by first changing into the directory then running `cargo run`. For example:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd examples/status-show
|
||||||
|
cargo run
|
||||||
|
```
|
||||||
2
examples/package-list/.gitignore
vendored
Normal file
2
examples/package-list/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
.env
|
||||||
|
target/
|
||||||
1862
examples/package-list/Cargo.lock
generated
Normal file
1862
examples/package-list/Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load diff
8
examples/package-list/Cargo.toml
Normal file
8
examples/package-list/Cargo.toml
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
[package]
|
||||||
|
name = "package-list"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2024"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
ckanaction = "0.2.0"
|
||||||
|
tokio = { version = "1.52.2", features = ["full"] }
|
||||||
8
examples/package-list/README.md
Normal file
8
examples/package-list/README.md
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
# Example of using ckanaction to run the /package_list API endpoint
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
the following command to run the `/package_list` CKAN Action API endpoint on `http://localhost:5000` and print the formatted debug output.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cargo run
|
||||||
|
```
|
||||||
15
examples/package-list/src/main.rs
Normal file
15
examples/package-list/src/main.rs
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
use ckanaction::CKANError;
|
||||||
|
|
||||||
|
#[tokio::main]
|
||||||
|
async fn main() -> Result<(), CKANError> {
|
||||||
|
// Initialize and build CKAN struct
|
||||||
|
let ckan = ckanaction::CKAN::builder()
|
||||||
|
.url("http://localhost:5000")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
// Send request to /package_list and print formatted debug output
|
||||||
|
let package_list = ckan.package_list().call().await?;
|
||||||
|
println!("{package_list:#?}");
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
668
examples/status-show/Cargo.lock
generated
668
examples/status-show/Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
|
@ -5,4 +5,4 @@ edition = "2024"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
ckanaction = "0.2.0"
|
ckanaction = "0.2.0"
|
||||||
tokio = { version = "1.49.0", features = ["full"] }
|
tokio = { version = "1.52.2", features = ["full"] }
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue