gin-gonic / gin

Gin is a HTTP web framework written in Go (Golang). It features a Martini-like API with much better performance -- up to 40 times faster. If you need smashing performance, get yourself some Gin.

Home Page:https://gin-gonic.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Extend the routing tree entry

Yjppj opened this issue · comments

  • With issues:
    • Use the search tool before opening a new issue.
    • Please provide source code and commit sha if you found a bug.
    • Review existing issues and provide feedback or react to them.

Description

I want to use the prefix tree of Gin now. I hope to register a DINGEVENT method and build a prefix tree for this method at the same time. This step is no problem, and the following code can be used:

type MyRouterGroup struct {
	RouterGroup *gin.RouterGroup
}

func (group *MyRouterGroup) DingEvent(event_url string, handlerFunc gin.HandlerFunc) {
	group.RouterGroup.Handle("DINGEVENT", event_url, handlerFunc)
}

However, I have no way to enter this routing tree (unless I modify the Gin source code), because only when an HTTP request is sent, will it be matched in the routing tree.

Is there a custom method that allows me to match the routing tree like processing HTTP requests?

Environment

  • go version: 1.21
  • gin version (or commit ref): 1.8
  • operating system: Mac