fix: gateway routing, add EnsureCreated to all services, register CorrelationIdMiddleware#36
Open
devin-ai-integration[bot] wants to merge 2 commits into
Open
fix: gateway routing, add EnsureCreated to all services, register CorrelationIdMiddleware#36devin-ai-integration[bot] wants to merge 2 commits into
devin-ai-integration[bot] wants to merge 2 commits into
Conversation
…relationIdMiddleware
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Four fixes for the microservices platform:
Fix 1: YARP Gateway Routing (
src/ApiGateway/appsettings.json)Replaced
PathRemovePrefixtransforms withPathPatterntransforms. 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 servicesAdded 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
CorrelationIdMiddlewarein all services and the gatewayShared.Infrastructureproject reference toApiGateway.csproj(the 5 domain services already had it).using Shared.Infrastructure.Middleware;andapp.UseMiddleware<CorrelationIdMiddleware>();to all 6Program.csfiles (5 services + gateway). The middleware addsX-Correlation-IDheaders for request tracing.Fix 4: Correct Shared project reference paths and ApiGateway Dockerfile
.csprojfiles: changed..\..\Shared\to..\..\..\Shared\(the old path resolved tosrc/Services/Shared/which doesn't exist — correct path issrc/Shared/).ApiGateway/Dockerfileto COPY the Shared project files needed for the newShared.Infrastructurereference.Review & Testing Checklist for Human
cd src && docker compose up --buildand verify all 6 services start (note: customer-service may need a restart if it starts before Postgres is ready)curl http://localhost:5000/api/customers(and/api/orders,/api/products,/api/identity,/api/notifications) — all should return valid JSONcurl http://localhost:5001/api/identity(ports 5001-5005)curl -v http://localhost:5000/api/customers 2>&1 | grep -i X-Correlation-IDNotes
docker compose up --build. All gateway and direct service endpoints return valid JSON.X-Correlation-IDheader confirmed present in responses.usingstatements were added.Link to Devin session: https://partner-workshops.devinenterprise.com/sessions/fce7fd433a214ce0a9b5c1b48cf9ba4d