优化gin
This commit is contained in:
parent
054cbb910e
commit
1ceea92959
|
|
@ -10,9 +10,16 @@ import (
|
|||
)
|
||||
|
||||
func Service(conf *Config) {
|
||||
if conf == nil {
|
||||
conf = &Config{
|
||||
RootPath: "/",
|
||||
Addr: "0.0.0.0",
|
||||
Port: 80,
|
||||
}
|
||||
}
|
||||
go func() {
|
||||
router := gin.New()
|
||||
routerSetup(router)
|
||||
routerSetup(router, &conf.RootPath)
|
||||
s := &http.Server{
|
||||
Addr: fmt.Sprintf("%s:%d", conf.Addr, conf.Port),
|
||||
Handler: router,
|
||||
|
|
|
|||
|
|
@ -1,15 +1,17 @@
|
|||
package gin
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
//路由配置
|
||||
func routerSetup(router *gin.Engine) {
|
||||
func routerSetup(router *gin.Engine, rootpath *string) {
|
||||
router.Use(gin.Recovery())
|
||||
router.GET(`/health/check`)
|
||||
|
||||
r := router.Group(`/user`)
|
||||
r := router.Group(fmt.Sprintf("/%s", *rootpath))
|
||||
{
|
||||
r.POST(`/register`)
|
||||
r.GET(`/accountcheck/:accname`)
|
||||
|
|
|
|||
Loading…
Reference in New Issue