Skip to content

feat: [#728] add http.Info and http.Name methods#1125

Merged
hwbrzzl merged 2 commits intomasterfrom
bowen/#728
Jul 12, 2025
Merged

feat: [#728] add http.Info and http.Name methods#1125
hwbrzzl merged 2 commits intomasterfrom
bowen/#728

Conversation

@hwbrzzl
Copy link
Contributor

@hwbrzzl hwbrzzl commented Jul 12, 2025

📑 Description

Closes goravel/goravel#728

Add two new methods:

ctx.Request().Info()
ctx.Request().Name()

✅ Checks

  • Added test cases for my code

Copilot AI review requested due to automatic review settings July 12, 2025 10:11
@hwbrzzl hwbrzzl requested a review from a team as a code owner July 12, 2025 10:11
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces two new methods (Info() and Name()) on the HTTP request context and migrates route metadata from the route contract to the new http.Info type across the codebase.

  • Replaced route.Info with http.Info in contracts, mocks, command code, and tests
  • Added Name() and Info() methods (and corresponding Info struct) to ContextRequest and updated its mocks
  • Refactored RouteListCommand to use the new http.Info type and standalone helper functions

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
route/console/route_list_command_test.go Updated imports, switched expected type to []http.Info, and renamed test function
route/console/route_list_command.go Refactored to use http.Info, replaced receiver methods with standalone helpers, updated display
mocks/route/Route.go Changed GetRoutes and Info mock signatures to return http.Info
mocks/http/ContextRequest.go Added mocks for new Info() and Name() methods on ContextRequest
contracts/route/route.go Updated interface methods to return contractshttp.Info and removed local Info struct
contracts/http/request.go Added Name() and Info() to ContextRequest and defined new Info struct
contracts/http/method.go Reordered constants and added new HTTP method types (ANY, RESOURCE, STATIC, etc.)
Comments suppressed due to low confidence (3)

route/console/route_list_command.go:151

  • [nitpick] The function name formateNameHandler appears to have a typo; consider renaming it to formatNameHandler for clarity and consistency.
func formateNameHandler(name, handler string) string {

route/console/route_list_command_test.go:16

  • [nitpick] Go test functions conventionally use camel-case names without underscores; consider renaming this back to TestRouteListCommand.
func Test_RouteListCommand(t *testing.T) {

contracts/http/request.go:22

  • The newly added Name() and Info() methods on ContextRequest lack unit tests; consider adding tests to verify their expected behavior.
	Name() string

@codecov
Copy link

codecov bot commented Jul 12, 2025

Codecov Report

Attention: Patch coverage is 93.33333% with 1 line in your changes missing coverage. Please review.

Project coverage is 66.82%. Comparing base (fe8bfb1) to head (c726b8b).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
route/console/route_list_command.go 93.33% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1125   +/-   ##
=======================================
  Coverage   66.82%   66.82%           
=======================================
  Files         214      214           
  Lines       14104    14104           
=======================================
  Hits         9425     9425           
  Misses       4303     4303           
  Partials      376      376           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member

@devhaozi devhaozi left a comment

Choose a reason for hiding this comment

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

LGTM

@hwbrzzl hwbrzzl merged commit 18aec32 into master Jul 12, 2025
15 checks passed
@hwbrzzl hwbrzzl deleted the bowen/#728 branch July 12, 2025 10:20
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.

希望可以直接获取当前的路由Name或路由信息方法

3 participants