refactor(consul): 统一Traefik路由规则格式并简化whoami配置

- 将所有服务的Traefik路由规则从点分隔符改为下划线格式
- 简化whoami服务配置,移除中间件并更新路由规则
- 统一所有服务的配置格式以提高可维护性
This commit is contained in:
fanfpy 2025-07-01 16:38:55 +08:00
parent f7cdfcbd1d
commit da3f845591
7 changed files with 17 additions and 20 deletions

View File

@ -9,7 +9,7 @@
"id": "data-service-1", "id": "data-service-1",
"meta": { "meta": {
"traefik_enable": "true", "traefik_enable": "true",
"traefik.http.routers.data-service.rule": "PathPrefix('/api/data')" "traefik_http_routers_data_service_rule": "PathPrefix('/api/data')"
}, },
"name": "data-service", "name": "data-service",
"port": 8000 "port": 8000

View File

@ -9,7 +9,7 @@
"id": "emotion-service-1", "id": "emotion-service-1",
"meta": { "meta": {
"traefik_enable": "true", "traefik_enable": "true",
"traefik.http.routers.emotion-service.rule": "PathPrefix('/api/emotion')" "traefik_http_routers_emotion_service_rule": "PathPrefix('/api/emotion')"
}, },
"name": "emotion-service", "name": "emotion-service",
"port": 8002 "port": 8002

View File

@ -9,7 +9,7 @@
"id": "frontend-1", "id": "frontend-1",
"meta": { "meta": {
"traefik_enable": "true", "traefik_enable": "true",
"traefik.http.routers.frontend.rule": "PathPrefix('/')" "traefik_http_routers_frontend_rule": "PathPrefix('/')"
}, },
"name": "frontend", "name": "frontend",
"port": 80 "port": 80

View File

@ -9,7 +9,7 @@
"id": "quant-service-1", "id": "quant-service-1",
"meta": { "meta": {
"traefik_enable": "true", "traefik_enable": "true",
"traefik.http.routers.quant-service.rule": "PathPrefix('/api/quant')" "traefik_http_routers_quant_service_rule": "PathPrefix('/api/quant')"
}, },
"name": "quant-service", "name": "quant-service",
"port": 8001 "port": 8001

View File

@ -9,7 +9,7 @@
"id": "recommend-service-1", "id": "recommend-service-1",
"meta": { "meta": {
"traefik_enable": "true", "traefik_enable": "true",
"raefik.http.routers.quant-service.rule": "PathPrefix(`/api/recommend`)" "traefik_http_routers_recommend_service_rule": "PathPrefix('/api/recommend')"
}, },
"name": "recommend-service", "name": "recommend-service",
"port": 8003 "port": 8003

View File

@ -9,7 +9,7 @@
"id": "user-service-1", "id": "user-service-1",
"meta": { "meta": {
"traefik_enable": "true", "traefik_enable": "true",
"raefik.http.routers.quant-service.rule": "PathPrefix(`/api/user`)" "traefik_http_routers_user_service_rule": "PathPrefix('/api/user')"
}, },
"name": "user-service", "name": "user-service",
"port": 8004 "port": 8004

View File

@ -1,23 +1,20 @@
{ {
"service": { "service": {
"name": "whoami", "name": "whoami",
"address": "whoami",
"port": 80,
"tags": [ "tags": [
"traefik.enable=true", "traefik.enable=true",
"traefik.http.routers.whoami.rule=Host(`whoami.localhost`)",
"traefik.http.routers.whoami.entrypoints=web", "traefik.http.routers.whoami.entrypoints=web",
"traefik.http.routers.whoami.middlewares=whoami-prefix" "traefik.http.routers.whoami.rule=Path(`/whoami`)",
"traefik.http.services.whoami.loadbalancer.server.port=80"
], ],
"check": { "address": "whoami",
"http": "http://whoami:80/", "port": 80,
"interval": "10s" "checks": [
} {
}, "http": "http://whoami:80/",
"middleware": { "interval": "10s",
"name": "whoami-prefix", "timeout": "2s"
"pathPrefixStrip": { }
"prefixes": ["/whoami"] ]
}
} }
} }