This is a simple ASP.NET Core Web API that performs CRUD operations for managing users. The API supports creating, retrieving, updating, and deleting users with validation and middleware logging.
- CRUD operations (GET, POST, PUT, DELETE)
- Input validation using data annotations
- Custom logging middleware
- In-memory data storage
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/users | Get all users |
| GET | /api/users/{id} | Get user by ID |
| POST | /api/users | Create new user |
| PUT | /api/users/{id} | Update user |
| DELETE | /api/users/{id} | Delete user |
{
"id": 3,
"name": "Charlie",
"email": "charlie@example.com",
"age": 28
}- Name must be between 2 and 100 characters
- Email must be valid format
- Age must be between 1 and 120
Custom request logging middleware logs:
- HTTP method
- Request path
- Response status code
dotnet restore
dotnet runI used GitHub Copilot to:
- Generate CRUD controller logic
- Debug API route handling
- Implement logging middleware
- Improve validation logic
All suggestions were reviewed and refined before use.
Use curl:
curl http://localhost:5134/api/usersThis API successfully demonstrates CRUD operations, validation, and middleware integration, fulfilling the assignment requirements.