{{- if .Values.gatewayAPI.enabled }}
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: {{ include "barycenter.fullname" . }}
  labels:
    {{- include "barycenter.labels" . | nindent 4 }}
  {{- with .Values.gatewayAPI.annotations }}
  annotations:
    {{- toYaml . | nindent 4 }}
  {{- end }}
spec:
  {{- with .Values.gatewayAPI.parentRefs }}
  parentRefs:
    {{- toYaml . | nindent 4 }}
  {{- end }}
  {{- with .Values.gatewayAPI.hostnames }}
  hostnames:
    {{- toYaml . | nindent 4 }}
  {{- end }}
  rules:
  - matches:
    - path:
        type: PathPrefix
        value: /
    backendRefs:
    - name: {{ include "barycenter.fullname" . }}
      port: {{ .Values.service.port }}
      {{- if .Values.gatewayAPI.backendWeight }}
      weight: {{ .Values.gatewayAPI.backendWeight }}
      {{- end }}
    {{- with .Values.gatewayAPI.filters }}
    filters:
      {{- toYaml . | nindent 4 }}
    {{- end }}
{{- end }}
