gin-gonic / examples

A repository to host examples and tutorials for Gin.
https://gin-gonic.com/docs/
MIT License
3.67k stars 641 forks source link

How can i add or remove router after gin server started dynamically? #130

Closed snowdream closed 4 months ago

snowdream commented 1 year ago

For Example:

can i add or remove router after gin server started dynamically? (after r.Run())

package main

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

func main() {
    r := gin.Default()
    r.GET("/ping", func(c *gin.Context) {
        c.JSON(200, gin.H{
            "message": "pong",
        })
    })
    r.Run() // 监听并在 0.0.0.0:8080 上启动服务
}
appleboy commented 4 months ago

move to https://github.com/gin-gonic/gin/issues/776