func (s *Server) listNamespace(c *gin.Context) {
	var err error
	r := &ListNamespaceResp{RetHeader: &RetHeader{RetCode: -1, RetMessage: ""}}
	cluster := c.DefaultQuery("cluster", s.cfg.DefaultCluster)
	r.Data, err = service.ListNamespace(s.cfg, cluster)
	if err != nil {
		log.Warn("list names of all namespace failed, %v", err)
		r.RetHeader.RetMessage = err.Error()
		c.JSON(http.StatusOK, r)
		return
	}
	r.RetHeader.RetCode = 0
	r.RetHeader.RetMessage = "SUCC"
	c.JSON(http.StatusOK, r)
	return
}
return names of all namespace
package cc
import (
	"fmt"
	"net"
	"net/http"
	"strings"
	"github.com/gin-contrib/gzip"
	"github.com/gin-gonic/gin"
	"github.com/nooncall/shazam/cc/service"
	"github.com/nooncall/shazam/log"
	"github.com/nooncall/shazam/models"
)
type Server struct {
	cfg *models.CCConfig
	engine   *gin.Engine
	listener net.Listener
	exitC chan struct{}
}
type RetHeader struct {
	RetCode    int    `json:"ret_code"`
	RetMessage string `json:"ret_message"`
}
func NewServer(addr string, cfg *models.CCConfig) (*Server, error) {
	srv := &Server{cfg: cfg, exitC: make(chan struct{})}
	srv.engine = gin.New()
	l, err := net.Listen("tcp", addr)
	if err != nil {
		return nil, err
	}
	srv.listener = l
	srv.registerURL()
	return srv, nil
}
func (s *Server) registerURL() {
	api := s.engine.Group("/api/cc", gin.BasicAuth(gin.Accounts{s.cfg.AdminUserName: s.cfg.AdminPassword}))
	api.Use(gin.Recovery())
	api.Use(gzip.Gzip(gzip.DefaultCompression))
	api.Use(func(c *gin.Context) {
		c.Writer.Header().Set("Content-Type", "application/json; charset=utf-8")
	})
	api.GET("/namespace/list", s.listNamespace)
	api.GET("/namespace", s.queryNamespace)
	api.PUT("/namespace/modify", s.modifyNamespace)
	api.PUT("/namespace/delete/:name", s.delNamespace)
	api.GET("/namespace/sqlfingerprint/:name", s.sqlFingerprint)
	api.GET("/proxy/config/fingerprint", s.proxyConfigFingerprint)
}
type ListNamespaceResp struct {
	RetHeader *RetHeader `json:"ret_header"`
	Data      []string   `json:"data"`
}