Skip to content

refactor: remove http_methods dependency#515

Open
Deepak8858 wants to merge 1 commit intodart-lang:masterfrom
Deepak8858:fix/remove-http-methods-dependency
Open

refactor: remove http_methods dependency#515
Deepak8858 wants to merge 1 commit intodart-lang:masterfrom
Deepak8858:fix/remove-http-methods-dependency

Conversation

@Deepak8858
Copy link
Copy Markdown

Fixes #512 by removing the http_methods dependency and inlining a simple _isHttpMethod check. This reduces dependencies outside the Dart team and facilitates using shelf_router in the Dart SDK.

@google-cla
Copy link
Copy Markdown

google-cla bot commented Mar 20, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 refactors the shelf_router and shelf_router_generator packages by eliminating an external dependency. By inlining a small utility function, the project reduces its reliance on third-party packages, making it more self-contained and easier to integrate, particularly for use within the Dart SDK. This change improves maintainability and simplifies the dependency graph without altering core functionality.

Highlights

  • Dependency Removal: The external http_methods package dependency has been entirely removed from both shelf_router and shelf_router_generator packages.
  • Inlined HTTP Method Check: A simple, private _isHttpMethod utility function has been inlined directly into router.dart and shelf_router_generator.dart to replace the functionality previously provided by the http_methods package.
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.

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.

Copy link
Copy Markdown
Contributor

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

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 successfully removes the http_methods dependency by inlining an _isHttpMethod check. This is a good simplification that reduces external dependencies. I've made a couple of suggestions to improve the efficiency of the new _isHttpMethod function by making the set of methods a compile-time constant. Overall, this is a solid improvement.

Comment on lines +309 to +310
return {'GET', 'HEAD', 'POST', 'PUT', 'DELETE', 'CONNECT', 'OPTIONS', 'TRACE', 'PATCH'}
.contains(method.toUpperCase());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

To improve performance, you can make the Set a compile-time constant by adding the const keyword. This prevents the set from being re-created on every call to _isHttpMethod.

  return const {'GET', 'HEAD', 'POST', 'PUT', 'DELETE', 'CONNECT', 'OPTIONS', 'TRACE', 'PATCH'}
      .contains(method.toUpperCase());

Comment on lines +341 to +342
return {'GET', 'HEAD', 'POST', 'PUT', 'DELETE', 'CONNECT', 'OPTIONS', 'TRACE', 'PATCH'}
.contains(method.toUpperCase());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

To improve performance, you can make the Set a compile-time constant by adding the const keyword. This prevents the set from being re-created on every call to _isHttpMethod.

Suggested change
return {'GET', 'HEAD', 'POST', 'PUT', 'DELETE', 'CONNECT', 'OPTIONS', 'TRACE', 'PATCH'}
.contains(method.toUpperCase());
return const {'GET', 'HEAD', 'POST', 'PUT', 'DELETE', 'CONNECT', 'OPTIONS', 'TRACE', 'PATCH'}
.contains(method.toUpperCase());

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Avoid http_methods dependency

2 participants