This is a template project for building a REST API using the Actix web framework in Rust.
- Actix web framework for building asynchronous web applications
- RESTful API structure
- CRUD operations example
- JSON serialization and deserialization with serde
- Error handling with custom error types
-
Clone this repository:
git clone https://github.com/Kim-DaeHan/actix-rest-template.git cd actix-rest-template -
Build and run the project:
cargo build cargo run
The server will start at http://localhost:8080.
-
Explore the API using your preferred API client or tools like cURL, Postman, or curl:
-
Get all post:
curl http://localhost:8080/api/posts
-
Get a specific post:
curl http://localhost:8080/api/posts/{id} -
Create a new post:
curl -X POST -H "Content-Type: application/json" -d '{"title": "New Post", "body": "Post Body", "published": true}' http://localhost:8080/api/posts
-
Update an post:
curl -X PUT -H "Content-Type: application/json" -d '{"id": "uuid", "title": "Update Post", "body": "Update Body", "published": true}' http://localhost:8080/api/posts
-
Delete an item:
curl -X DELETE http://localhost:8080/api/posts/{id}
-
docker build:
docker build -t actix_rest_template . -
docker run:
docker run -p 8080:8080 actix_rest_template