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

feat: add dynamic routing header generation #887

Merged
merged 5 commits into from
Feb 17, 2022

Conversation

alicejli
Copy link
Contributor

@alicejli alicejli commented Feb 3, 2022

Add support for the google.api.routing annotation. In short, this annotation allows API producers to explicitly define those request fields should be include in request headers/metadata. Furthermore, it enables API producers to define simple segment matchers (primarily for resource name values) that are generated into regular expressions in the client that extract segments of a field's value to be sent in the header. Finally, it enables API producers to specify a key other than the field name to use in the header key-value-pair. In relation to the implicit headers (extraced from google.api.http annotations), the google.api.routing annotation takes precedence. Please read the annotation documentation for more information on the annotation resolution logic.

  • This includes a gapic-showcase integration test

@alicejli alicejli marked this pull request as ready for review February 3, 2022 17:34
@alicejli alicejli requested review from a team as code owners February 3, 2022 17:34
internal/gengapic/helpers.go Outdated Show resolved Hide resolved
internal/gengapic/helpers.go Outdated Show resolved Hide resolved
internal/gengapic/helpers.go Outdated Show resolved Hide resolved
internal/gengapic/helpers.go Outdated Show resolved Hide resolved
internal/gengapic/helpers.go Show resolved Hide resolved
internal/gengapic/gengapic.go Outdated Show resolved Hide resolved
internal/gengapic/gengapic.go Outdated Show resolved Hide resolved
internal/gengapic/gengapic.go Outdated Show resolved Hide resolved
internal/gengapic/testdata/method_GetAnotherThing.want Outdated Show resolved Hide resolved
internal/gengapic/gengapic.go Outdated Show resolved Hide resolved
@noahdietz
Copy link
Collaborator

Great great start to this Alice! This is a tough feature and you are integrating it marvelously.

Copy link
Collaborator

@noahdietz noahdietz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great adjustments.

internal/gengapic/gengapic.go Outdated Show resolved Hide resolved
internal/gengapic/gengapic.go Outdated Show resolved Hide resolved
internal/gengapic/gengapic.go Outdated Show resolved Hide resolved
internal/gengapic/gengapic.go Outdated Show resolved Hide resolved
internal/gengapic/gengapic.go Outdated Show resolved Hide resolved
internal/gengapic/gengapic.go Outdated Show resolved Hide resolved
internal/gengapic/gengapic.go Outdated Show resolved Hide resolved
internal/gengapic/testdata/method_GetAnotherThing.want Outdated Show resolved Hide resolved
Copy link
Collaborator

@noahdietz noahdietz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking really good!

internal/gengapic/doc_file.go Outdated Show resolved Hide resolved
showcase/echo_test.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@noahdietz noahdietz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Way to go, Alice, well done.

got = strings.Split(got[0], "&")
sort.Strings(got)
sort.Strings(tst.want)
if !reflect.DeepEqual(got, tst.want) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: use cmp.Diff (look around the codebase for uses) to compare to values in a test. This can be done in another PR though.

@alicejli alicejli merged commit e2520c7 into googleapis:main Feb 17, 2022
@alicejli alicejli deleted the dynamicRoutingHeader branch February 17, 2022 23:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants