Actix Web framework'ü ve PostgreSQL kullanılarak geliştirilmiş modern bir Rust microservice projesi.
- ✅ RESTful API endpoints
- ✅ PostgreSQL veritabanı entegrasyonu
- ✅ SQLx ile async database işlemleri
- ✅ JSON serialization/deserialization
- ✅ CORS desteği
- ✅ Request logging
- ✅ Health check endpoint
- ✅ CRUD işlemleri
- ✅ UUID kullanımı
- ✅ Modüler yapı
- ✅ Hata yönetimi
- Rust (1.70+)
- PostgreSQL (12+)
- PostgreSQL'i yükleyin ve çalıştırın:
# macOS ile Homebrew
brew install postgresql
brew services start postgresql
# Ubuntu/Debian
sudo apt-get install postgresql
sudo service postgresql start- Veritabanını oluşturun:
# Postgres kullanıcısıyla
createdb rustmicro
# veya SQL ile
psql -U postgres -c "CREATE DATABASE rustmicro;"- .env dosyasını kontrol edin (zaten mevcut):
cat .env # DATABASE_URL'yi kontrol edinNot: Tablolar, indeksler ve örnek veriler otomatik olarak oluşturulacak!
- Projeyi klonlayın veya indirin
- Environment değişkenlerini ayarlayın:
cp .env.example .env
# .env dosyasını düzenleyin- Projeyi derleyin:
cargo buildcargo runServer başarıyla başladığında http://localhost:8080 adresinde çalışacaktır.
- GET
/- API'ye hoş geldin mesajı
- GET
/health- API'nin durumunu kontrol eder
- GET
/api/v1/users- Tüm kullanıcıları listeler - POST
/api/v1/users- Yeni kullanıcı oluşturur - GET
/api/v1/users/{id}- ID'ye göre kullanıcı getirir - PUT
/api/v1/users/{id}- Kullanıcı bilgilerini günceller - DELETE
/api/v1/users/{id}- Kullanıcıyı siler
- GET
/api/v1/stats- Kullanıcı istatistikleri
- GET
/api/v1/ports- Tüm limanları listeler - POST
/api/v1/ports- Yeni liman oluşturur - POST
/api/v1/ports/nearest- En yakın limanı bulur (latitude ve longitude gereklidir) - GET
/api/v1/ports/country/{country}- Ülkeye göre limanları listeler - GET
/api/v1/ports/type/{port_type}- Liman tipine göre limanları listeler
curl http://localhost:8080/api/v1/userscurl -X POST http://localhost:8080/api/v1/users \\
-H "Content-Type: application/json" \\
-d '{"name": "Ahmet Yılmaz", "email": "[email protected]"}'curl http://localhost:8080/api/v1/users/550e8400-e29b-41d4-a716-446655440000curl -X PUT http://localhost:8080/api/v1/users/550e8400-e29b-41d4-a716-446655440000 \\
-H "Content-Type: application/json" \\
-d '{"name": "Ahmet Yeni Ad", "email": "[email protected]"}'curl -X DELETE http://localhost:8080/api/v1/users/550e8400-e29b-41d4-a716-446655440000curl http://localhost:8080/api/v1/statscurl http://localhost:8080/healthBu proje aşağıdaki teknolojileri kullanır:
- Actix Web: High-performance web framework
- SQLx: Async SQL toolkit
- PostgreSQL: Relational database
- Tokio: Async runtime
- Serde: Serialization framework
- UUID: Unique identifier generation
- Chrono: Date and time handling
- Actix CORS: CORS middleware
- env_logger: Logging
- Veritabanı entegrasyonu (PostgreSQL)
- CRUD işlemleri
- UUID kullanımı
- Hata yönetimi
- Database migrations (sqlx migrate)
- Otomatik veritabanı kurulum
- Environment configuration (.env)
- Authentication/Authorization (JWT)
- Input validation (validator crate)
- Unit & integration tests
- API documentation (OpenAPI)
- Docker containerization
- Health check endpoint improvements
- Logging improvements (structured logs)
- Rate limiting
- Caching (Redis)