This is a small project for learning more Rust. It is a rewrite of this project started in Go by my friend Marcelo metal Jorge Vieira.
This package uses Rocket, which currently only builds with Rust nightly. This is about to change but, for now, if you are using rustup make sure you have the nightly toolchain installed and run this on the project's directory:
rustup override set nightlyOtherwise make sure you always add +nightly when calling cargo. The following command will build and run the HTTP server:
cargo +nightly runIf all goes well you should now be able to look at the Swagger UI nicely provided by rocket-okapi:
http://localhost:8000/swagger-ui/
curl \
http://localhost:8000/stocks/operations \
-X POST \
-H 'Content-Type: application/json' \
-d '{
"portfolio": "default", "symbol": "PETR4", "type": "purchase", "broker": "Clear",
"quantity": 500, "price": 10, "time": "2020-04-24T00:00:00Z", "fees": 0
}'curl \
http://localhost:8000/stocks/operations \
-X POST \
-H 'Content-Type: application/json' \
-d '{
"portfolio": "default", "symbol": "PETR4", "type": "sale", "broker": "Clear",
"quantity": 500, "price": 10, "time": "2020-04-24T00:00:00Z", "fees": 0
}'curl \
http://localhost:8000/stocks/position/PETR4