server:
  port: 6000
spring:
  application:
    name: gateway
  profiles:
    active: @profile.active@
  cloud:
    loadbalancer:
      ribbon:
        enabled: false
    gateway:
      # 默认过滤器(对所有 route 均生效)
      default-filters:
        # 限流配置
        - name: MyRequestRateLimiter
          args:
            # 如果 keyResolver 返回空 key 则拒绝请求返回 403, 默认 true 表示拒绝, false 表示允许访问
            deny-empty-key: false
            # 自定义的 KeyResolver(从请求 exchange 解析 id 来区分独立的限流单元, id 可以是 userId, remoteAddr, sessionId 等)
            key-resolver: "#{@keyResolver}"
#            rate-limiter: "#{@myRateLimiter}"
#            my-rate-limiter.requestedTokens: 1
            rate-limiter: "#{@redisRateLimiter}"
            # 令牌桶算法每秒补充的 token 数量(每秒的请求数量)
            redis-rate-limiter.replenishRate: 100
            # 令牌桶算法的 token 最大数量(每秒的最大请求数量)
            redis-rate-limiter.burstCapacity: 150
            # 单次请求消费的 token 数量
            redis-rate-limiter.requestedTokens: 1
      routes:
        - id: account-router
          # spring-cloud-starter-zookeeper-discovery 提供服务发现功能
          uri: lb://account-service
          predicates:
            - Path=/api/account/**
          filters:
            - StripPrefix=0
        - id: static-router
          uri: lb://account-service
          predicates:
            - Path=/dist/images/**
          filters:
            - StripPrefix=0
        - id: auth-router
          uri: lb://account-service
          predicates:
            - Path=/api/auth/**
          filters:
            - StripPrefix=0
        - id: oauth-router
          uri: lb://account-service
          predicates:
            - Path=/oauth/**
          filters:
            - StripPrefix=0
        - id: user-router
          uri: lb://user-service
          predicates:
            - Path=/api/user/**
          filters:
            - StripPrefix=0
        ###############################################################################
        - id: content-router
          uri: lb://content-service
          predicates:
            - Path=/api/content/**
          filters:
            - StripPrefix=0
        - id: timeline-router
          uri: lb://content-service
          predicates:
            - Path=/api/timeline/**
          filters:
            - StripPrefix=0
        - id: search-router
          uri: lb://content-service
          predicates:
            - Path=/api/search/**
          filters:
            - StripPrefix=0
        - id: comment-router
          uri: lb://content-service
          predicates:
            - Path=/api/comment/**
          filters:
            - StripPrefix=0
        - id: mall-router
          uri: lb://content-service
          predicates:
            - Path=/api/mall/**
          filters:
            - StripPrefix=0
        - id: geo-router
          uri: lb://content-service
          predicates:
            - Path=/api/geo/**
          filters:
            - StripPrefix=0
        - id: im-router
          uri: lb://content-service
          predicates:
            - Path=/api/chat/**
          filters:
            - StripPrefix=0
        ###############################################################################
        - id: data-router
          uri: lb://data-service
          #uri: http://192.168.0.39:6005
          predicates:
            - Path=/api/data/**
          filters:
            - StripPrefix=0
        ###############################################################################
        - id: file-router
          uri: lb://file-service
          predicates:
            - Path=/api/file/**
          filters:
            - StripPrefix=0
        ###############################################################################
        - id: message-websocket
          uri: lb:ws://message-service
          predicates:
            - Path=/ws/**
        - id: message-router
          uri: lb://message-service
          predicates:
            - Path=/api/message/**
        ###############################################################################
        - id: log-websocket
          uri: lb:ws://search-service
          predicates:
            - Path=/logws/**
        - id: search1-router
          uri: lb://search-service
          predicates:
            - Path=/api/search1/**
#    gateway:
#      globalcors:
#        cors-configurations:
#          '[/**]':
#            allowedOrigins: "*"
#            allowedMethods: "*"
#            allowedHeaders: "*"
eureka:
  instance:
    prefer-ip-address: true
  client:
    register-with-eureka: true
    fetch-registry: true