Skip to content

feat: router groups#14

Merged
joseph-beck merged 10 commits into
mainfrom
feat/router-groups
Dec 19, 2025
Merged

feat: router groups#14
joseph-beck merged 10 commits into
mainfrom
feat/router-groups

Conversation

@joseph-beck

Copy link
Copy Markdown
Owner

Adds router groups to amp!

Create a router group with

func main() {
	g := amp.Group("/group")
	g.Get("/hello", func(ctx *amp.Ctx) error {
		return ctx.Render(200, "hello world!")
	})

	a := amp.New()

	a.Group(g)

	log.Fatalln(a.ListenAndServe())
}

Copilot AI left a comment

Copy link
Copy Markdown

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 adds router groups functionality to the amp web framework, allowing developers to organize routes under common prefixes with shared middleware. This is a common pattern in web frameworks that improves code organization and reduces duplication.

Key changes:

  • Introduces a new group type and Group() function for creating route groups with prefixes and middleware
  • Adds Mux.Group() method to register groups with the router
  • Includes comprehensive unit tests for all group methods

Reviewed changes

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

Show a summary per file
File Description
pkg/amp/group.go Defines the core group types and methods for creating and managing route groups with HTTP method handlers
pkg/amp/group_test.go Comprehensive unit tests for all group struct methods and functionality
pkg/amp/mux.go Adds Mux.Group() method to register groups and additional logging for server startup
go.mod Updates Go version to 1.25
.github/workflows/go.yml Updates CI workflow to use Go 1.25 and reformats YAML structure
examples/group/main.go Demonstrates usage of the new router groups feature
examples/group/README.md Brief documentation for the group example

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

Comment thread pkg/amp/mux.go
Comment thread pkg/amp/mux.go
Comment thread pkg/amp/group.go Outdated
Comment thread pkg/amp/group.go Outdated
Comment thread pkg/amp/mux.go Outdated
Comment thread pkg/amp/group.go Outdated
@joseph-beck joseph-beck merged commit f4ea885 into main Dec 19, 2025
2 checks passed
@joseph-beck joseph-beck deleted the feat/router-groups branch December 19, 2025 18:34
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