From 894e75a5876e4adb3f87a5900e362cb6c74714f4 Mon Sep 17 00:00:00 2001 From: Rohan Sircar Date: Sat, 1 Aug 2020 19:18:49 +0530 Subject: [PATCH] Updated readme --- README.md | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/README.md b/README.md index 351fc5c..22ffbc9 100644 --- a/README.md +++ b/README.md @@ -1 +1,45 @@ Testing out the Rust framework Actix-Web to create a JSON API CRUD Web App. + +## API Demo + +### Get Users + +``` +curl -X GET http://localhost:7800/api/users/get/1 +``` + +``` +{"name":"user1","registration_date":"2020-05-09T06:17:26"} +``` + +``` +curl -X GET http://localhost:7800/api/users/get +``` + +``` +[{"name":"user1","registration_date":"2020-05-09T06:17:26"},{"name":"user2","registration_date":"2020-05-12T12:43:13"},{"name":"user3","registration_date":"2020-05-15T07:47:50"}] +``` + +### Create User + +``` +curl -H "content-type: application/json" -X POST http://localhost:7800/do_registration --data '{"name":"user4","password":"test"}' +``` + +``` +[{"name":"user1","registration_date":"2020-05-09T06:17:26"},{"name":"user2","registration_date":"2020-05-12T12:43:13"},{"name":"user3","registration_date":"2020-05-15T07:47:50"},{"name":"user4","registration_date":"2020-08-01T05:04:05"}] +``` + +### DTO Validation + +``` +curl -H "content-type: application/json" -X POST http://localhost:7800/do_registration --data '{"name":"abc","password":"test"}' +``` + +``` +ValidationErrors({"name": Field([ValidationError { code: "length", message: None, params: {"value": String("abc"), "min": Number(4), "max": Number(10)} }])}) +``` + +## Memory Usage + +Memory usage as compared to interpreted language was my primary motivation for looking into rust as a backend language. As of writing, the demo app uses only 1.3MB of memory.