-
Notifications
You must be signed in to change notification settings - Fork 436
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
contrib/google.golang.org/api: add google api integration #313
Conversation
…uration, add example
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A bit "resourcey" but very nice and accurate! Consider unexporting the tree logic.
|
||
type ( | ||
// A Tree is a prefix tree for matching endpoints based on http requests. | ||
Tree struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do any of these need to be part of the public API? I'm thinking not. In which case we can make them unexported. I'd check with godoc
to make sure nothing extra is there and it's all easy to figure out from a user perspective.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't able to make it private because the generator script is not in the same package. I could make it internal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It has to be private because there is no use for this in the public API. If I'm wrong go ahead and keep it. Otherwise we should hide it. If we have to create an internal
package for that then maybe we should.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's keep it. It can't hurt, and if anyone ever wants to add some custom endpoints, they can...
Thanks Caleb! Added further commits and merged. |
Implements the API portion of: #312. A separate pull request will implement the Cloud portion (which uses this integration behind the scenes).
I made a
Tree
class which is a lot like a prefix tree where the "words" are path segments, and a map is used to store children instead of an array. Finally a regular expression is generated using a uritemplate package as a final check that a path matches.The Tree is filled via a
make_endpoints.go
script which parses the JSON files in the package to discover every possible API endpoint.