Skip to content

Commit d252ae4

Browse files
committed
Add Copilot instructions
Add .github/copilot-instructions.md containing contributor and Copilot guidance: build/test commands, high-level project architecture, runtime module responsibilities, web-endpoint routing behavior, and key conventions (custom we:// scheme, per-route exclusions, feature flags). Intended to help contributors and automated tooling understand build steps, auto-configuration registration, and testing conventions.
1 parent c81c8f0 commit d252ae4

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

.github/copilot-instructions.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Copilot Instructions
2+
3+
## Build and test commands
4+
5+
- Build all modules: `./mvnw -DskipTests package`
6+
- Run the full test suite: `./mvnw test`
7+
- Run one test class from a leaf module: `./mvnw -pl microsphere-spring-cloud-gateway-server-webflux -am -Dtest=WebEndpointMappingGlobalFilterTest -Dsurefire.failIfNoSpecifiedTests=false test`
8+
- CI also exercises compatibility profiles with commands like `./mvnw -Drevision=0.0.1-SNAPSHOT test -Ptest,coverage,spring-cloud-2021` and the same profile set for `spring-cloud-hoxton` and `spring-cloud-2020`
9+
10+
## High-level architecture
11+
12+
- The root `pom.xml` is a Maven reactor. `microsphere-gateway-parent` imports the Microsphere Spring Cloud BOM, and `microsphere-gateway-dependencies` publishes the BOM that downstream applications import.
13+
- `microsphere-spring-cloud-gateway-commons` contains the shared gateway contract: property constants, conditional annotations, `WebEndpointConfig`, and `WebEndpointConfigurationPropertiesBindHandlerAdvisor`. That advisor injects typed `metadata.web-endpoint` config into bound `spring.cloud.gateway.routes[*]` definitions.
14+
- `microsphere-spring-cloud-gateway-server-webflux` is the runtime module. It registers auto-configuration in both `META-INF/spring.factories` and `META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports`, and uses `WebEndpointApplicationContextInitializer` to install the bind-handler advisor before route properties are bound.
15+
- The main runtime feature is web-endpoint routing. Gateway routes that use `uri: we://...` and usually `Path=/{application}/**` are intercepted by `WebEndpointMappingGlobalFilter`, which loads `WebEndpointMapping` metadata from discovered service instances, caches request-mapping candidates per route, rewrites the downstream path, adds the endpoint mapping ID header, and forwards to a load-balanced target instance.
16+
- `GatewayAutoConfiguration` also replaces Spring Cloud Gateway's `FilteringWebHandler` with `CachingFilteringWebHandler`, and wires listeners/interceptors that refresh route state on successful route refreshes, environment changes, and service-instance changes while suppressing heartbeat-triggered refresh noise.
17+
18+
## Key conventions
19+
20+
- The custom route scheme is `we`. `we://all` subscribes to every discovered service; otherwise the URI host names the subscribed services.
21+
- Per-route web-endpoint exclusions live under `spring.cloud.gateway.routes[*].metadata.web-endpoint.excludes` and use Spring request-mapping fields such as `patterns`, `methods`, `params`, `headers`, `consumes`, and `produces`.
22+
- Gateway features are layered behind property-based conditional annotations and default to enabled: `spring.cloud.gateway.enabled`, `microsphere.spring.cloud.gateway.enabled`, and `microsphere.spring.cloud.web-endpoint-mapping.enabled`.
23+
- When changing auto-configuration, keep both registration files in sync: `spring.factories` and `AutoConfiguration.imports`.
24+
- Tests rely on shared YAML fixtures in `src/test/resources/META-INF/config/default/test.yaml`. WebFlux integration-style tests commonly activate the `simple-service-registry,gateway` profiles and use `@EnableWebFluxExtension`.

0 commit comments

Comments
 (0)