Skip to content

zupzup/example-rust-json-input-validation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

example-rust-json-input-validation

An example for doing basic JSON input validation with Rust, using warp.

Run with cargo run and then:

For basic, and improved JSON parse handling:

curl -X POST http://localhost:8080/create-basic -H "Content-Type: application/json" -d '{ "email": 1, "address": { "street": "warpstreet", "street_no": 1 }, "pets": [{ "name": "nacho" }] }'

curl -X POST http://localhost:8080/create-path -H "Content-Type: application/json" -d '{ "email": 1, "address": { "street": "warpstreet", "street_no": 1 }, "pets": [{ "name": "nacho" }] }'

And for validating the outcoming struct:

curl -X POST http://localhost:8080/create-validator -H "Content-Type: application/json" -d '{ "email": "chip@example.com", "address": { "street": "warpstreet", "street_no": 1 }, "pets": [{ "name": "" }] }'

About

Example of doing JSON input validation in a rust web service

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages