Skip to content

Adding the posibility to proxy the google route requests#130

Open
TheSayvior wants to merge 3 commits into
Dammyololade:mainfrom
TheSayvior:main
Open

Adding the posibility to proxy the google route requests#130
TheSayvior wants to merge 3 commits into
Dammyololade:mainfrom
TheSayvior:main

Conversation

@TheSayvior

Copy link
Copy Markdown

Hello, we few changes, if you want them.

Added proxy option as in earlier version, since I have to proxy the request to conceal the API key from anyone getting access to the app source code.

Changed the "Route" class to "PolylineRoute" to avoid import errors with other packages or flutter itself since Route is a commonly used class name

Great package, thanks for the work you do on this.

@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello @TheSayvior, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the PolylinePoints library by integrating proxy support for Google Maps API requests, offering a robust solution for API key security. Additionally, it refines the internal class structure by renaming 'Route' to 'PolylineRoute', thereby preventing common naming collisions in Flutter projects and improving overall API design. These changes provide developers with greater flexibility and security when working with Google Maps routing functionalities.

Highlights

  • Proxy Support for Google Routes API: Introduced a 'proxy' option across the PolylinePoints library, allowing users to route Google Maps API requests through a custom proxy server. This helps in securing API keys by preventing their direct exposure in client-side code.
  • Flexible API Key Handling: The 'apiKey' parameter is now optional and nullable in PolylinePoints constructors and network methods. An assertion ensures that either an API key or a proxy is provided, but not both or neither, enforcing correct usage.
  • Class Renaming for Clarity: The 'Route' class within 'lib/src/routes_api/routes_response.dart' has been renamed to 'PolylineRoute'. This change resolves potential naming conflicts with Flutter's built-in 'Route' class, improving code maintainability and avoiding import errors.
  • Example App Updates: The example application has been updated to demonstrate the usage of the new 'proxy' parameter in various map screens, reflecting the changes in the core library.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request introduces two valuable changes: the ability to proxy Google route requests to protect API keys, and the renaming of the Route class to PolylineRoute to prevent naming conflicts. The implementation is well-executed and consistent across the library and example app. I've found one issue in an assertion which I've commented on. Once that's addressed, this PR will be a great addition.

Comment thread lib/src/network/network_provider.dart Outdated
Comment on lines +41 to +44
(request.proxy == null &&
googleApiKey != null &&
googleApiKey.isNotEmpty) ||
(request.proxy != null && googleApiKey == null),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

The assertion here incorrectly uses request.proxy to check for the presence of a proxy. However, the proxy URI is passed as the proxy parameter to this function. This assertion should use the proxy parameter to be consistent with the logic in getRouteBetweenCoordinatesV2 and the PolylinePoints constructor.

Suggested change
(request.proxy == null &&
googleApiKey != null &&
googleApiKey.isNotEmpty) ||
(request.proxy != null && googleApiKey == null),
(proxy == null &&
googleApiKey != null &&
googleApiKey.isNotEmpty) ||
(proxy != null && googleApiKey == null),

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