瀏覽代碼

fix show handler

Michael Yang 1 年之前
父節點
當前提交
aac9ab4db7
共有 1 個文件被更改,包括 3 次插入4 次删除
  1. 3 4
      server/routes.go

+ 3 - 4
server/routes.go

@@ -630,11 +630,10 @@ func ShowModelHandler(c *gin.Context) {
 		return
 		return
 	}
 	}
 
 
-	var model string
 	if req.Model != "" {
 	if req.Model != "" {
-		model = req.Model
+		// noop
 	} else if req.Name != "" {
 	} else if req.Name != "" {
-		model = req.Name
+		req.Model = req.Name
 	} else {
 	} else {
 		c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"error": "model is required"})
 		c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"error": "model is required"})
 		return
 		return
@@ -643,7 +642,7 @@ func ShowModelHandler(c *gin.Context) {
 	resp, err := GetModelInfo(req)
 	resp, err := GetModelInfo(req)
 	if err != nil {
 	if err != nil {
 		if os.IsNotExist(err) {
 		if os.IsNotExist(err) {
-			c.JSON(http.StatusNotFound, gin.H{"error": fmt.Sprintf("model '%s' not found", model)})
+			c.JSON(http.StatusNotFound, gin.H{"error": fmt.Sprintf("model '%s' not found", req.Model)})
 		} else {
 		} else {
 			c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
 			c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
 		}
 		}