{#
SPDX-FileCopyrightText: 2025 MDAD project contributors

SPDX-License-Identifier: AGPL-3.0-or-later
#}

{% if matrix_bridge_steam_container_labels_traefik_enabled %}
traefik.enable=true

{% if matrix_bridge_steam_container_labels_traefik_docker_network %}
traefik.docker.network={{ matrix_bridge_steam_container_labels_traefik_docker_network }}
{% endif %}

traefik.http.services.matrix-steam-bridge.loadbalancer.server.port={{ matrix_bridge_steam_appservice_port }}

{% if matrix_bridge_steam_public_media_enabled %}
############################################################
#                                                          #
# Public Media                                             #
#                                                          #
############################################################

# Router for public media
traefik.http.routers.matrix-steam-bridge-public-media.rule=Host(`{{ matrix_server_fqn_matrix }}`) && PathPrefix(`/_mautrix/publicmedia/{{ matrix_domain }}/`)
traefik.http.routers.matrix-steam-bridge-public-media.service=matrix-steam-bridge
traefik.http.routers.matrix-steam-bridge-public-media.entrypoints={{ matrix_bridge_steam_container_labels_traefik_entrypoints }}
traefik.http.routers.matrix-steam-bridge-public-media.tls={{ matrix_bridge_steam_container_labels_traefik_tls | to_json }}
{% if matrix_bridge_steam_container_labels_traefik_tls %}
traefik.http.routers.matrix-steam-bridge-public-media.tls.certResolver={{ matrix_bridge_steam_container_labels_traefik_tls_certResolver }}
{% endif %}


############################################################
#                                                          #
# /Public Media                                            #
#                                                          #
############################################################
{% endif %}

{% if matrix_bridge_steam_container_labels_exposure_enabled %}
############################################################
#                                                          #
# Bridge API exposure                                      #
#                                                          #
############################################################

traefik.http.middlewares.matrix-steam-bridge-exposure-strip-prefix.stripprefix.prefixes={{ matrix_bridge_steam_exposure_path_prefix }}
traefik.http.routers.matrix-steam-bridge-exposure.middlewares=matrix-steam-bridge-exposure-strip-prefix

traefik.http.routers.matrix-steam-bridge-exposure.rule={{ matrix_bridge_steam_container_labels_exposure_traefik_rule }}

{% if matrix_bridge_steam_container_labels_exposure_traefik_priority | int > 0 %}
traefik.http.routers.matrix-steam-bridge-exposure.priority={{ matrix_bridge_steam_container_labels_exposure_traefik_priority }}
{% endif %}

traefik.http.routers.matrix-steam-bridge-exposure.service=matrix-steam-bridge
traefik.http.routers.matrix-steam-bridge-exposure.entrypoints={{ matrix_bridge_steam_container_labels_exposure_traefik_entrypoints }}

traefik.http.routers.matrix-steam-bridge-exposure.tls={{ matrix_bridge_steam_container_labels_exposure_traefik_tls | to_json }}
{% if matrix_bridge_steam_container_labels_exposure_traefik_tls %}
traefik.http.routers.matrix-steam-bridge-exposure.tls.certResolver={{ matrix_bridge_steam_container_labels_exposure_traefik_tls_certResolver }}
{% endif %}

############################################################
#                                                          #
# /Bridge API exposure                                     #
#                                                          #
############################################################
{% endif %}


{% endif %}

{{ matrix_bridge_steam_container_labels_additional_labels }}
