/rust_go_fun_2024

Fun with Rust, Go, and MongoDB

Primary LanguageGo

rust_go_fun

Run the following from the root dir:

docker-compose up

# If using Docker Compose Engine V2:
docker compose up

Endpoint testing is supplied through bash:

bash curl_test_go_mongo.sh
bash curl_test_rust_actix.sh
bash curl_test_rust_mongo.sh
bash curl_test_workers.sh
# bash curl_test_all.sh

Go

  1. https://localhost:443/public/
  2. https://localhost:443/public/queryworker.html
  3. https://localhost:443/public/querystatus.html
  4. https://localhost:443/public/querystatuses.html
  5. https://localhost:443/public/addworker.html
  6. https://localhost:443/public/stopworker.html

Defaults:

  • User and password for basic auth: test, test
  • a and b are commands that are supplied in the request - they correspond to the bash scripts in /go/bin
  • Simple password auth isn't enterprise-grade security (obviously) but is added to demonstrate basic auth checking

Worker

  1. POST https://localhost:443/api/create?user=test&password=test&cmd=a&scheduled=2024-05-08T15:04:05Z
  2. GET https://localhost:443/api/status?user=test&password=test&uuid=5e44e582-7af4-4751-9dd8-9385c25e1e99
  3. GET https://localhost:443/api/workers?user=test&password=test
  4. GET https://localhost:443/api/jobs?user=test&password=test&uuid=5e44e582-7af4-4751-9dd8-9385c25e1e99
  5. POST https://localhost:443/api/stop?user=test&password=test&uuid=5e44e582-7af4-4751-9dd8-9385c25e1e99

Example

Mongo DB:

  1. GET https://localhost:443/api/examples
  2. GET https://localhost:443/api/example/one?id=1
  3. DELETE https://localhost:443/api/example/delete?id=1
  4. POST https://localhost:443/api/example/create?id=1&name=a&val=a
  5. PUT https://localhost:443/api/example/update?id=1&name=c&val=c

Rust

Working my way through some Rust and Actix Server documentation.

  1. http://localhost:8000/
  2. http://localhost:8000/echo
  3. http://localhost:8000/hey

Example

  1. GET http://localhost:8000/examples
  2. GET http://localhost:8000/example/one?id=1
  3. DELETE http://localhost:8000/example/delete?id=1
  4. POST http://localhost:8000/example/create?id=1&name=a&val=a
  5. PUT http://localhost:8000/example/update?id=1&name=c&val=c

Resources and Links

  1. https://doc.rust-lang.org/rust-by-example/index.html
  2. https://ntex.rs/docs/application
  3. https://hub.qovery.com/guides/tutorial/create-a-blazingly-fast-api-in-rust-part-1/#overview
  4. https://actix.rs/docs/getting-started
  5. https://github.com/tfogo/mongodb-go-tutorial/blob/master/main.go
  6. https://pkg.go.dev/net/url#URL.Query
  7. https://stackoverflow.com/questions/55564562/what-is-the-bson-syntax-for-set-in-updateone-for-the-official-mongo-go-driver
  8. https://github.com/Mr-Malomz/actix-mongo-api/blob/main/src/repository/mongodb_repo.rs
  9. https://crates.io/crates/mongodb