Skip to content

kliarist/animals

Repository files navigation

Animal rest api

A rust crud rest api poc using:

  • axum
  • diesel
  • envconfig
  • tracing
  • postgres

Build

Build using cargo build --release.

Run

Run using ./target/release/animals-api.

Development

Bring the postgres docker container up by docker-compose up -d database. Check Diesel documentation for installing the diesel cli and libmq.

For local development it makes sense to use cargo-watch.

Get it using cargo install cargo-watch and start the

application using cargo watch -x run to enjoy file watching and reloading.

Diesel migrations

To add a new migration please use diesel migration generate <migration_name>.

To run migrations manually use diesel migration run.

To rollback migrations use diesel migration redo.

The migrations are run automatically on application startup.

Dockerize

To build the docker image use docker build -t animals-api ..

Goals for this project

  • CRUD requests
  • Connect to a database
  • Externalise configuration/properties
  • Dockerise
  • Logging/Tracing
  • Global and local api error handling
  • Add JWT security
  • Release process

Useful links

Axum

Diesel

Envconfig

Tracing

About

Just a sample rust axum rest api

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published