Go to file
Rohan Sircar 565e6bc5e4 Changes to ci
instead of docker layer caching, build binary in runner itself and copy
binary to dockerfile
old Dockerfile is now build.Dockerfile whereas new one is ci.Dockerfile
caching docker layers was taking more time than building the image from
 scratch
 add powerpc build (for the 100th time) but without cross in it's own
 job
2021-04-24 22:46:11 +05:30
.github/workflows Changes to ci 2021-04-24 22:46:11 +05:30
db minor enhancements 2021-04-23 21:10:02 +05:30
migrations/2020-05-02-115427_create_users Many updates 2020-05-09 12:07:08 +05:30
src fix dockerfile 2021-04-23 23:01:14 +05:30
static first commit 2020-05-06 18:56:24 +05:30
templates first commit 2020-05-06 18:56:24 +05:30
.env minor enhancements 2021-04-23 21:10:02 +05:30
.gitignore minor enhancements 2021-04-23 21:10:02 +05:30
app.db minor enhancements 2021-04-23 21:10:02 +05:30
build.Dockerfile Changes to ci 2021-04-24 22:46:11 +05:30
build.Dockerfile.dockerignore Changes to ci 2021-04-24 22:46:11 +05:30
Cargo.lock many changes 2021-04-22 23:26:30 +05:30
Cargo.toml minor enhancements 2021-04-23 21:10:02 +05:30
ci.Dockerfile Changes to ci 2021-04-24 22:46:11 +05:30
ci.Dockerfile.dockerignore Changes to ci 2021-04-24 22:46:11 +05:30
diesel.toml first commit 2020-05-06 18:56:24 +05:30
README.md update readme 2021-04-21 11:22:24 +05:30
rustfmt.toml Implemented basic auth logic + other stuff 2020-05-12 01:03:11 +05:30

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 \
-i 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 \
-i http://localhost:7800/do_registration \
--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)} }])})

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 less than 50MB of memory.