| 114 | } |
| 115 | |
| 116 | func RequiredClusterShard(c *gin.Context) { |
| 117 | s, _ := c.MustGet(consts.ContextKeyStore).(*store.ClusterStore) |
| 118 | cluster, err := s.GetCluster(c, c.Param("namespace"), c.Param("cluster")) |
| 119 | if err != nil { |
| 120 | helper.ResponseError(c, err) |
| 121 | return |
| 122 | } |
| 123 | |
| 124 | shardIndex, err := strconv.Atoi(c.Param("shard")) |
| 125 | if err != nil { |
| 126 | helper.ResponseBadRequest(c, err) |
| 127 | return |
| 128 | } |
| 129 | shard, err := cluster.GetShard(shardIndex) |
| 130 | if err != nil { |
| 131 | helper.ResponseError(c, err) |
| 132 | return |
| 133 | } |
| 134 | |
| 135 | c.Set(consts.ContextKeyCluster, cluster) |
| 136 | c.Set(consts.ContextKeyClusterShard, shard) |
| 137 | c.Next() |
| 138 | } |
| 139 | |
| 140 | func RequiredRaftEngine(c *gin.Context) { |
| 141 | storage, _ := c.MustGet(consts.ContextKeyStore).(*store.ClusterStore) |