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

feat(engine): Added methods that support OptionFunc #3890

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

flc1125
Copy link
Contributor

@flc1125 flc1125 commented Mar 14, 2024

Example:

package main

import (
	"net/http"

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

func main() {
	router := gin.New(
		// middleware
		gin.Use(gin.Recovery(), gin.Logger()),

		// routes
		gin.GET("/get", func(c *gin.Context) {}),
		gin.GET("/get/another", func(c *gin.Context) {}),
		gin.POST("/post", func(c *gin.Context) {}),
		gin.PUT("/put", func(c *gin.Context) {}),
		gin.DELETE("/delete", func(c *gin.Context) {}),
		gin.PATCH("/patch", func(c *gin.Context) {}),
		gin.HEAD("/head", func(c *gin.Context) {}),
		gin.OPTIONS("/options", func(c *gin.Context) {}),
		gin.Any("/any", func(c *gin.Context) {}),

		// group
		gin.Group("/group", func(group *gin.RouterGroup) {
			group.GET("/get", func(c *gin.Context) {})
			group.GET("/get/another", func(c *gin.Context) {})
		}),

		// route
		gin.Route("GET", "/route", func(c *gin.Context) {}),

		// no route
		gin.NoRoute(func(c *gin.Context) {}),

		// static
		gin.Static("/static", "/var/www"),
		gin.StaticFile("/favicon.ico", "/var/www/favicon.ico"),
		gin.StaticFS("/static", http.Dir("/var/www")),

		// custom
		router(),
	)

	router.Run(":8080")
}

func router() func(router *gin.Engine) {
	return func(router *gin.Engine) {
		router.GET("/custom", func(c *gin.Context) {})
	}
}

Copy link

codecov bot commented Mar 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.20%. Comparing base (3dc1cd6) to head (159d883).
Report is 36 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3890      +/-   ##
==========================================
- Coverage   99.21%   99.20%   -0.02%     
==========================================
  Files          42       44       +2     
  Lines        3182     2756     -426     
==========================================
- Hits         3157     2734     -423     
+ Misses         17       12       -5     
- Partials        8       10       +2     
Flag Coverage Δ
?
-tags "sonic avx" 99.19% <100.00%> (?)
-tags go_json 99.19% <100.00%> (?)
-tags nomsgpack 99.18% <100.00%> (?)
go-1.18 99.12% <100.00%> (+<0.01%) ⬆️
go-1.19 99.20% <100.00%> (-0.02%) ⬇️
go-1.20 99.20% <100.00%> (-0.02%) ⬇️
go-1.21 99.20% <100.00%> (-0.02%) ⬇️
go-1.22 99.20% <100.00%> (?)
macos-latest 99.20% <100.00%> (-0.02%) ⬇️
ubuntu-latest 99.20% <100.00%> (-0.02%) ⬇️

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

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

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.

None yet

1 participant