update readme

This commit is contained in:
Rohan Sircar 2021-04-21 11:22:24 +05:30
parent 1d1cff4f74
commit 5378124bf4

View File

@ -4,22 +4,22 @@ Testing out the Rust framework Actix-Web to create a JSON API CRUD Web App.
### Get Users ### Get Users
``` ```
curl -X GET http://localhost:7800/api/users/get/1 curl -X GET http://localhost:7800/api/users/get/1
``` ```
``` ```
{ {
"name": "user1", "name": "user1",
"registration_date": "2020-05-09T06:17:26" "registration_date": "2020-05-09T06:17:26"
} }
``` ```
``` ```
curl -X GET http://localhost:7800/api/users/get curl -X GET http://localhost:7800/api/users/get
``` ```
``` ```
[ [
{ {
"name": "user1", "name": "user1",
@ -38,14 +38,14 @@ curl -X GET http://localhost:7800/api/users/get
### Create User ### Create User
``` ```
curl -H "content-type: application/json" \ curl -H "content-type: application/json" \
-X POST \ -X POST \
-i http://localhost:7800/do_registration \ -i http://localhost:7800/do_registration \
--data '{"name":"user4","password":"test"}' --data '{"name":"user4","password":"test"}'
``` ```
``` ```
[ [
{ {
"name": "user1", "name": "user1",
@ -68,17 +68,17 @@ curl -H "content-type: application/json" \
### DTO Validation ### DTO Validation
``` ```
curl -H "content-type: application/json" \ curl -H "content-type: application/json" \
-X POST \ -X POST \
-i http://localhost:7800/do_registration \ -i http://localhost:7800/do_registration \
--data '{"name":"abc","password":"test"}' # min length for name is 4 --data '{"name":"abc","password":"test"}' # min length for name is 4
``` ```
``` ```
ValidationErrors({"name": Field([ValidationError { code: "length", message: None, params: {"value": String("abc"), "min": Number(4), "max": Number(10)} }])}) ValidationErrors({"name": Field([ValidationError { code: "length", message: None, params: {"value": String("abc"), "min": Number(4), "max": Number(10)} }])})
``` ```
## Memory Usage ## Memory Usage
Memory usage as compared to interpreted languages was my primary motivation for looking into rust as a backend language. As of writing, the demo app uses only 1.3MB of memory. Memory usage as compared to interpreted languages was my primary motivation for looking into rust as a backend language. As of writing, the demo app uses less than 50MB of memory.