Skip to content

Conversation

@evaogbe
Copy link
Contributor

@evaogbe evaogbe commented Nov 3, 2017

Example:

routing_header = google.api_core.gapic_v1.routing_header(
            [('name', name), ('book.read', book.read)])
self._create_book(request, retry=retry, timeout=timeout, metadata=[routing_header])

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Nov 3, 2017

"""Helpers for handling routing header params."""

METADATA_KEY = 'x-goog-header-params'

This comment was marked as spam.


def to_routing_header(params):
"""Returns the routing header string that the params form"""
return "&".join(["{}={}".format(*pair) for pair in params])

This comment was marked as spam.

params = [('name', 'meep'), ('book.read', True)]
metadata = routing_header.to_grpc_metadata(params)
assert metadata == (
routing_header.METADATA_KEY, "name=meep&book.read=True")

This comment was marked as spam.

"""Helpers for handling routing header params."""


try:

This comment was marked as spam.

ROUTING_METADATA_KEY = 'x-goog-header-params'


def _to_url_string(x):

This comment was marked as spam.


def to_routing_header(params):
"""Returns the routing header string that the params form"""
return urlencode(params)

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@theacodes theacodes merged commit 10ef028 into googleapis:master Nov 8, 2017
parthea pushed a commit that referenced this pull request Nov 24, 2025
* api_core: Add routing header

* Fix linting

* Review fixes

* More review fixes

* Documentation fixes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: core cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants