示例#1
0
文件: rest.go 项目: trebogeer/cbft
// NewRESTRouter creates a mux.Router initialized with the REST
// API and web UI routes.  See also InitStaticRouter if you need finer
// control of the router initialization.
func NewRESTRouter(versionMain string, mgr *cbgt.Manager,
	staticDir, staticETag string, mr *cbgt.MsgRing) (
	*mux.Router, map[string]rest.RESTMeta, error) {
	return rest.InitRESTRouter(InitStaticRouter(staticDir, staticETag),
		versionMain, mgr, staticDir, staticETag, mr,
		myAssetDir, myAsset)
}
示例#2
0
func addCbgtRoutes(router *mux.Router, sc *ServerContext) error {

	// only do this if CBGT is enabled
	if !sc.config.ClusterConfig.CBGTEnabled() {
		return nil
	}

	// likewise, if there are no index writers and CBGT is not initialized, skip this
	if !sc.HasIndexWriters() {
		return nil
	}

	subrouter := router.PathPrefix("/_cbgt").Subrouter()

	versionString := "0.0.0"
	staticDir := ""
	staticETag := ""
	var messageRing *cbgt.MsgRing
	assetDir := rest.AssetDir
	asset := rest.Asset

	cbgtManager := sc.CbgtContext.Manager
	_, _, err := rest.InitRESTRouter(
		subrouter,
		versionString,
		cbgtManager,
		staticDir,
		staticETag,
		messageRing,
		assetDir,
		asset,
	)
	if err != nil {
		return err
	}
	return nil
}