Skip to content

fix: gateway routing, add EnsureCreated to all services, register CorrelationIdMiddleware#36

Open
devin-ai-integration[bot] wants to merge 2 commits into
mainfrom
fix/all-bugs
Open

fix: gateway routing, add EnsureCreated to all services, register CorrelationIdMiddleware#36
devin-ai-integration[bot] wants to merge 2 commits into
mainfrom
fix/all-bugs

Conversation

@devin-ai-integration
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot commented May 12, 2026

Summary

Four fixes for the microservices platform:

Fix 1: YARP Gateway Routing (src/ApiGateway/appsettings.json)

Replaced PathRemovePrefix transforms with PathPattern transforms. The old config stripped the entire prefix, leaving just / or /{id}, but backend controllers expect paths like /api/customer, /api/order, etc. The gateway now correctly rewrites plural paths (/api/customers) to singular controller routes (/api/customer).

Fix 2: Add EnsureCreated() to 4 services

Added the EnsureCreated() database initialization block (already present in Notification service) to Identity, Customer, Order, and Product services. This ensures PostgreSQL tables are created on startup.

Fix 3: Register CorrelationIdMiddleware in all services and the gateway

  • Added Shared.Infrastructure project reference to ApiGateway.csproj (the 5 domain services already had it).
  • Added using Shared.Infrastructure.Middleware; and app.UseMiddleware<CorrelationIdMiddleware>(); to all 6 Program.cs files (5 services + gateway). The middleware adds X-Correlation-ID headers for request tracing.

Fix 4: Correct Shared project reference paths and ApiGateway Dockerfile

  • Fixed all 5 service .csproj files: changed ..\..\Shared\ to ..\..\..\Shared\ (the old path resolved to src/Services/Shared/ which doesn't exist — correct path is src/Shared/).
  • Updated ApiGateway/Dockerfile to COPY the Shared project files needed for the new Shared.Infrastructure reference.

Review & Testing Checklist for Human

  • Run cd src && docker compose up --build and verify all 6 services start (note: customer-service may need a restart if it starts before Postgres is ready)
  • Test gateway routing: curl http://localhost:5000/api/customers (and /api/orders, /api/products, /api/identity, /api/notifications) — all should return valid JSON
  • Test direct service access: curl http://localhost:5001/api/identity (ports 5001-5005)
  • Verify correlation ID headers: curl -v http://localhost:5000/api/customers 2>&1 | grep -i X-Correlation-ID

Notes

  • All fixes verified locally with docker compose up --build. All gateway and direct service endpoints return valid JSON. X-Correlation-ID header confirmed present in responses.
  • The Shared project reference path fix (Fix 4) was a pre-existing issue in the csproj files that became a build-breaking problem once the middleware using statements were added.

Link to Devin session: https://partner-workshops.devinenterprise.com/sessions/fce7fd433a214ce0a9b5c1b48cf9ba4d


Open in Devin Review

@devin-ai-integration
Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Copy link
Copy Markdown
Contributor Author

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 3 additional findings.

Open in Devin Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants