January 2019
Intermediate to advanced
520 pages
14h 32m
English
Compile this example and run it with the cargo run command. Use curl to send requests to the service. In the first request, we'll generate a random number with a uniform distribution:
$ curl --header "Content-Type: application/json" --request POST \ --data '{"distribution": "uniform", "parameters": {"start": -100, "end": 100}}' \ http://localhost:8080/random
We sent a POST request to the localhost:8080/random URL with a JSON body. This will return {"value":-55.0}.
The next command requests a shuffle of the "1234567890" binary string converted to Base64:
$ curl --header "Content-Type: application/json" --request POST \ --data '{"distribution": "shuffle", "parameters": { "data": "MTIzNDU2Nzg5MA==" } }' \ http://localhost:8080/random ...Read now
Unlock full access