apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: bitwarden-self-host-httproute
  namespace: bitwarden
spec:
  hostnames:
    - bw.localtest.me
  parentRefs:
    - group: gateway.networking.k8s.io
      kind: Gateway
      name: bw-gateway
      namespace: bitwarden
      sectionName: https
  rules:
    - matches:
        - path:
            type: PathPrefix
            value: /attachments
      filters:
        - type: URLRewrite
          urlRewrite:
            path:
              type: ReplacePrefixMatch
              replacePrefixMatch: /
      backendRefs:
        - name: bitwarden-self-host-attachments
          port: 5000
    - matches:
        - path:
            type: PathPrefix
            value: /api
      filters:
        - type: URLRewrite
          urlRewrite:
            path:
              type: ReplacePrefixMatch
              replacePrefixMatch: /
      backendRefs:
        - name: bitwarden-self-host-api
          port: 5000
    - matches:
        - path:
            type: PathPrefix
            value: /icons
      filters:
        - type: URLRewrite
          urlRewrite:
            path:
              type: ReplacePrefixMatch
              replacePrefixMatch: /
      backendRefs:
        - name: bitwarden-self-host-icons
          port: 5000
    - matches:
        - path:
            type: PathPrefix
            value: /notifications
      filters:
        - type: URLRewrite
          urlRewrite:
            path:
              type: ReplacePrefixMatch
              replacePrefixMatch: /
      backendRefs:
        - name: bitwarden-self-host-notifications
          port: 5000
    - matches:
        - path:
            type: PathPrefix
            value: /events
      filters:
        - type: URLRewrite
          urlRewrite:
            path:
              type: ReplacePrefixMatch
              replacePrefixMatch: /
      backendRefs:
        - name: bitwarden-self-host-events
          port: 5000
    - matches:
        - path:
            type: PathPrefix
            value: /sso
      backendRefs:
        - name: bitwarden-self-host-sso
          port: 5000
    - matches:
        - path:
            type: PathPrefix
            value: /identity
      backendRefs:
        - name: bitwarden-self-host-identity
          port: 5000
    - matches:
        - path:
            type: PathPrefix
            value: /admin
      backendRefs:
        - name: bitwarden-self-host-admin
          port: 5000
    - matches:
        - path:
            type: PathPrefix
            value: /
      backendRefs:
        - name: bitwarden-self-host-web
          port: 5000