Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

api_core: Add routing header #4336

Merged
merged 5 commits into from
Nov 8, 2017

Conversation

eoogbe
Copy link
Contributor

@eoogbe eoogbe 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.

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.

None yet

3 participants