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

fix:disallow that a method don't match regEnLetter #3727

Closed
wants to merge 2 commits into from
Closed

fix:disallow that a method don't match regEnLetter #3727

wants to merge 2 commits into from

Conversation

bestgopher
Copy link
Contributor

@bestgopher bestgopher commented Sep 13, 2023

if I difine a custom method aaa, it can be registerd by Match, but can not by Handle.
The Handle will check the method by regEnLetter regexp rule.
I think the two ways should be consistent.

package main

import "github.com/gin-gonic/gin"

func main() {
	d := gin.Default()

	// use Match to register aaa will be ok.
	d.Match([]string{"aaa"}, "/aaa", func(c *gin.Context) {
		c.String(200, "aaa")
	})

	// use Handle to register aaa will panic.
	// panic: http method aaa is not valid
	d.Handle("aaa", "/aaa", func(c *gin.Context) {
		c.String(200, "aaa")
	})

	d.Run(":8080")
}

@codecov
Copy link

codecov bot commented Sep 13, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (c2ba8f1) 99.20% compared to head (d592e50) 99.20%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #3727   +/-   ##
=======================================
  Coverage   99.20%   99.20%           
=======================================
  Files          42       42           
  Lines        3157     3157           
=======================================
  Hits         3132     3132           
  Misses         17       17           
  Partials        8        8           
Flag Coverage Δ
99.20% <100.00%> (ø)
go-1.18 99.11% <100.00%> (ø)
go-1.19 99.20% <100.00%> (ø)
go-1.20 99.20% <100.00%> (ø)
macos-latest 99.20% <100.00%> (ø)
ubuntu-latest 99.20% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
routergroup.go 100.00% <100.00%> (ø)

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

@bestgopher bestgopher changed the title disallow that a method don't match regEnLetter fix:disallow that a method don't match regEnLetter Sep 16, 2023
@bestgopher bestgopher closed this by deleting the head repository Jan 6, 2024
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.

1 participant