A small and simple web service that returns JSON formatted pseudorandom data - numbers, hexadecimal numbers, UUIDs, and base 64 strings. An excuse to try out Crystal and the companion web framework, Kemal. I had thought it might be useful to have such random data sources for Workflow workflows.
- Install Crystal
shards install
crystal build --release src/randoms.cr
./randoms
- visit localhost:3000
/hex
returns JSON with data: {random: "b48ed003fbe56939b9b1715542146084"}/hex?length=3
returns JSON with data: {random: "b48ed0"}/number
returns JSON with data: {random: "88"}/number?length=10
returns JSON with data: {random: "8"}/uuid
returns JSON with data: {random: "fc07646c-c24b-4744-a31a-87c979a80e26"}/base64
returns JSON with data: {random: "KCbA8xgLGyddXMf6X3dzFg=="}
{
"method": "hex",
"data": {
"random": "f87b10c557f16361c9de82afbcfdd257"
},
"responded_at": "2016-12-27T21:20:57+0000"
}
KEMAL_ENV=test crystal spec
- Fork it ( https://github.com/chaserx/randoms/fork )
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create a new Pull Request
- chaserx Chase Southard