def do_GET(self, write_status_code_only: bool = False) -> None:
        """Process all GET requests which can not be routed to other methods.

        Is used for handling all health-checks requests. E.g. "GET /(primary|replica|sync|async|etc...)".

        The (optional) query parameters and the HTTP response status depend on the requested path:

            * ``/``, ``primary``, or ``read-write``:

                * HTTP status ``200``: if a primary with the leader lock.

            * ``/standby-leader``:

                * HTTP status ``200``: if holds the leader lock in a standby cluster.

            * ``/leader``:

                * HTTP status ``200``: if holds the leader lock.

            * ``/replica``:

                * Query parameters:

                    * ``lag``: only accept replication lag up to ``lag``. Accepts either an :class:`int`, which
                        represents lag in bytes, or a :class:`str` representing lag in human-readable format (e.g.
                        ``10MB``).
                    * Any custom parameter: will attempt to match them against node tags.

                * HTTP status ``200``: if up and running as a standby and without ``noloadbalance`` tag.

            * ``/read-only``:

                * HTTP status ``200``: if up and running and without ``noloadbalance`` tag.

            * ``/quorum``:

                * HTTP status ``200``: if up and running as a quorum synchronous standby.

            * ``/read-only-quorum``:

                * HTTP status ``200``: if up and running as a quorum synchronous standby or primary.

            * ``/synchronous`` or ``/sync``:

                * HTTP status ``200``: if up and running as a synchronous standby.

            * ``/read-only-sync``:

                * HTTP status ``200``: if up and running as a synchronous standby or primary.

            * ``/asynchronous``:

                * Query parameters:

                    * ``lag``: only accept replication lag up to ``lag``. Accepts either an :class:`int`, which
                        represents lag in bytes, or a :class:`str` representing lag in human-readable format (e.g.
                        ``10MB``).

                * HTTP status ``200``: if up and running as an asynchronous standby.

            * ``/health``:

                * HTTP status ``200``: if up and running.

        .. note::
            If not able to honor the query parameter, or not able to match the condition described for HTTP status
            ``200`` in each path above, then HTTP status will be ``503``.

        .. note::
            Independently of the requested path, if *write_status_code_only* is ``False``, then it always write an HTTP
            response through :func:`_write_status_response`, with the node status.

        :param write_status_code_only: indicates that instead of a normal HTTP response we should
                                       send only the HTTP Status Code and close the connection.
                                       Useful when health-checks are executed by HAProxy.
        """
        path = '/primary' if self.path == '/' else self.path
        response = self.get_postgresql_status()
        latest_end_lsn = response.pop('latest_end_lsn', 0)

        patroni = self.server.patroni
        cluster = patroni.dcs.cluster
        config = global_config.from_cluster(cluster)

        leader_optime = max(cluster and cluster.status.last_lsn or 0, latest_end_lsn)
        replayed_location = response.get('xlog', {}).get('replayed_location', 0)
        max_replica_lag = parse_int(self.path_query.get('lag', [sys.maxsize])[0], 'B')
        if max_replica_lag is None:
            max_replica_lag = sys.maxsize
        is_lagging = leader_optime and leader_optime > replayed_location + max_replica_lag

        replica_status_code = 200 if not patroni.noloadbalance and not is_lagging and \
            response.get('role') == PostgresqlRole.REPLICA and response.get('state') == PostgresqlState.RUNNING else 503

        if not cluster and response.get('pause'):
            leader_status_code = 200 if response.get('role') in (PostgresqlRole.PRIMARY,
                                                                 PostgresqlRole.STANDBY_LEADER) else 503
            primary_status_code = 200 if response.get('role') == PostgresqlRole.PRIMARY else 503
            standby_leader_status_code = 200 if response.get('role') == PostgresqlRole.STANDBY_LEADER else 503
        elif patroni.ha.is_leader():
            leader_status_code = 200
            if config.is_standby_cluster:
                primary_status_code = replica_status_code = 503
                standby_leader_status_code =\
                    200 if response.get('role') in (PostgresqlRole.REPLICA, PostgresqlRole.STANDBY_LEADER) else 503
            else:
                primary_status_code = 200
                standby_leader_status_code = 503
        else:
            leader_status_code = primary_status_code = standby_leader_status_code = 503

        status_code = 503

        ignore_tags = False
        if 'standby_leader' in path or 'standby-leader' in path:
            status_code = standby_leader_status_code
            ignore_tags = True
        elif 'leader' in path:
            status_code = leader_status_code
            ignore_tags = True
        elif 'master' in path or 'primary' in path or 'read-write' in path:
            status_code = primary_status_code
            ignore_tags = True
        elif 'replica' in path:
            status_code = replica_status_code
        elif 'read-only' in path and 'sync' not in path and 'quorum' not in path:
            status_code = 200 if 200 in (primary_status_code, standby_leader_status_code) else replica_status_code
        elif 'health' in path:
            status_code = 200 if response.get('state') == PostgresqlState.RUNNING else 503
        elif cluster:  # dcs is available
            is_quorum = response.get('quorum_standby')
            is_synchronous = response.get('sync_standby')
            if path in ('/sync', '/synchronous') and is_synchronous:
                status_code = replica_status_code
            elif path == '/quorum' and is_quorum:
                status_code = replica_status_code
            elif path in ('/async', '/asynchronous') and not is_synchronous and not is_quorum:
                status_code = replica_status_code
            elif path == '/read-only-quorum':
                if 200 in (primary_status_code, standby_leader_status_code):
                    status_code = 200
                elif is_quorum:
                    status_code = replica_status_code
            elif path in ('/read-only-sync', '/read-only-synchronous'):
                if 200 in (primary_status_code, standby_leader_status_code):
                    status_code = 200
                elif is_synchronous:
                    status_code = replica_status_code

        # check for user defined tags in query params
        if not ignore_tags and status_code == 200:
            qs_tag_prefix = "tag_"
            for qs_key, qs_value in self.path_query.items():
                if not qs_key.startswith(qs_tag_prefix):
                    continue
                qs_key = qs_key[len(qs_tag_prefix):]
                qs_value = qs_value[0]
                instance_tag_value = patroni.tags.get(qs_key)
                # tag not registered for instance
                if instance_tag_value is None:
                    status_code = 503
                    break
                if not isinstance(instance_tag_value, str):
                    instance_tag_value = str(instance_tag_value).lower()
                if instance_tag_value != qs_value:
                    status_code = 503
                    break

        if write_status_code_only:  # when haproxy sends OPTIONS request it reads only status code and nothing more
            self._write_status_code_only(status_code)
        else:
            self._write_status_response(status_code, response)
Process all GET requests which can not be routed to other methods.

        Is used for handling all health-checks requests. E.g. "GET /(primary|replica|sync|async|etc...)".

        The (optional) query parameters and the HTTP response status depend on the requested path:

            * ``/``, ``primary``, or ``read-write``:

                * HTTP status ``200``: if a primary with the leader lock.

            * ``/standby-leader``:

                * HTTP status ``200``: if holds the leader lock in a standby cluster.

            * ``/leader``:

                * HTTP status ``200``: if holds the leader lock.

            * ``/replica``:

                * Query parameters:

                    * ``lag``: only accept replication lag up to ``lag``. Accepts either an :class:`int`, which
                        represents lag in bytes, or a :class:`str` representing lag in human-readable format (e.g.
                        ``10MB``).
                    * Any custom parameter: will attempt to match them against node tags.

                * HTTP status ``200``: if up and running as a standby and without ``noloadbalance`` tag.

            * ``/read-only``:

                * HTTP status ``200``: if up and running and without ``noloadbalance`` tag.

            * ``/quorum``:

                * HTTP status ``200``: if up and running as a quorum synchronous standby.

            * ``/read-only-quorum``:

                * HTTP status ``200``: if up and running as a quorum synchronous standby or primary.

            * ``/synchronous`` or ``/sync``:

                * HTTP status ``200``: if up and running as a synchronous standby.

            * ``/read-only-sync``:

                * HTTP status ``200``: if up and running as a synchronous standby or primary.

            * ``/asynchronous``:

                * Query parameters:

                    * ``lag``: only accept replication lag up to ``lag``. Accepts either an :class:`int`, which
                        represents lag in bytes, or a :class:`str` representing lag in human-readable format (e.g.
                        ``10MB``).

                * HTTP status ``200``: if up and running as an asynchronous standby.

            * ``/health``:

                * HTTP status ``200``: if up and running.

        .. note::
            If not able to honor the query parameter, or not able to match the condition described for HTTP status
            ``200`` in each path above, then HTTP status will be ``503``.

        .. note::
            Independently of the requested path, if *write_status_code_only* is ``False``, then it always write an HTTP
            response through :func:`_write_status_response`, with the node status.

        :param write_status_code_only: indicates that instead of a normal HTTP response we should
                                       send only the HTTP Status Code and close the connection.
                                       Useful when health-checks are executed by HAProxy.
        
patroni/api.py