Skip to content

feat(http): radix tree matcher for route matching#12

Open
burakkoken wants to merge 2 commits intomainfrom
matcher
Open

feat(http): radix tree matcher for route matching#12
burakkoken wants to merge 2 commits intomainfrom
matcher

Conversation

@burakkoken
Copy link
Member

No description provided.

Copy link

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

Adds a radix-tree-based EndpointMatcher implementation to support fast route matching (static, params, glob-like patterns, *, and **) and enables ServerRequest.PathValue(...) to return captured path parameters.

Changes:

  • Introduces radixTreeMatcher with route registration + matching, including path normalization and param capture.
  • Adds per-request storage for captured path parameters and wires ServerRequest.PathValue(...) to it.
  • Adds extensive unit tests + a benchmark for matcher behavior and priority rules.

Reviewed changes

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

Show a summary per file
File Description
http/request.go Adds internal storage for captured path params; implements PathValue; changes Method() return type.
http/context.go Adds endpoint field + accessor/mutator and introduces NewContext.
http/endpoint.go Reorders fields in Endpoint (no functional change).
http/matcher.go New radix-tree matcher implementation and supporting helpers.
http/matcher_test.go New comprehensive matcher tests and benchmark.
Comments suppressed due to low confidence (1)

http/context.go:116

  • Context.reset clears request/response state but does not reset the newly added endpoint field or any captured pathValues. If Context instances are reused (as reset suggests), this can leak routing state between requests. Consider setting c.endpoint = nil and resetting c.req.pathValues here as well.
func (c *Context) reset(w http.ResponseWriter, r *http.Request) {
	c.err = nil
	clear(c.values)

	c.req.nativeReq = r
	c.req.cookiesCache = nil
	c.req.queryCache = nil


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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