diff --git a/program/http.go b/program/http.go index 8456158..293fb7e 100644 --- a/program/http.go +++ b/program/http.go @@ -39,7 +39,12 @@ func (p *Program) startAPI() { } // v1 api - apiV1 := router.Group("/v1", gin.BasicAuth(accounts)) + var apiV1 *gin.RouterGroup + if len(accounts) > 0 { + apiV1 = router.Group("/v1", gin.BasicAuth(accounts)) + } else { + apiV1 = router.Group("/v1") + } apiV1.Use(p.middlewareEtcd()) // 注入etcd客户端 v1.V1(apiV1)