"""Custom service registry.

Use this to specify custom service resolution rules, which can be
useful for testing.

Registration in this file takes precedence over grass/services.py.
The syntax is the same.

It is loaded only when running Grass in the `dev` environment.
"""

from grass.api import access
from grass.api import register
from grass.config import RULES_YML_PATH
from grass.connectors.service import OrchardWebService
from grass.protocols import rest

# Example override. Requests to `/features/<path>` will
# resolve to `http://myfeatures:8080/<path>`.

register(
    name='ows-features',
    rule='/features',
    metric='features',
    service=OrchardWebService(
        domain='myfeatures',
        url_protocol='http',
        port=8080,
        protocol=rest),
    access=[
        access.allow_session_access_for_routes(
            RULES_YML_PATH + 'ows-features.yml'),
        access.allow_client(),
        access.allow_jwt_token()])
