@seokho-son
μλ₯Ό λ€μ΄
[Call chain]
/:nsId/resources/image (src/api/rest/server/server.go)func RestPostImage (src/api/rest/server/mcir/image.go)μ΄ κΈ°λ₯μ
/:nsId/resources/image?action=registerWithInfo λ‘ νΈμΆλλ©΄TbImageInfo struct λ‘ Bind (unmarshal) νκ³ /:nsId/resources/image?action=registerWithId λ‘ νΈμΆλλ©΄TbImageReq struct λ‘ Bind (unmarshal) ν©λλ€.μ΄λ func RestPostImage μμμ if λ¬ΈμΌλ‘ ꡬνλμ΄ μμ΅λλ€.
action := c.QueryParam("action")
fmt.Println("[POST Image requested action: " + action)
/*
if action == "create" {
fmt.Println("[Creating Image]")
content, _ := createImage(nsId, u)
return c.JSON(http.StatusCreated, content)
} else */
if action == "registerWithInfo" {
fmt.Println("[Registering Image with info]")
u := &mcir.TbImageInfo{}
if err := c.Bind(u); err != nil {
return err
}
content, err := mcir.RegisterImageWithInfo(nsId, u)
if err != nil {
common.CBLog.Error(err)
mapA := map[string]string{"message": err.Error()}
return c.JSON(http.StatusFailedDependency, &mapA)
}
return c.JSON(http.StatusCreated, content)
} else if action == "registerWithId" {
fmt.Println("[Registering Image with ID]")
u := &mcir.TbImageReq{}
if err := c.Bind(u); err != nil {
return err
}
//content, responseCode, body, err := RegisterImageWithId(nsId, u)
content, err := mcir.RegisterImageWithId(nsId, u)
if err != nil {
common.CBLog.Error(err)
//fmt.Println("body: ", string(body))
//return c.JSONBlob(responseCode, body)
mapA := map[string]string{"message": err.Error()}
return c.JSON(http.StatusFailedDependency, &mapA)
}
return c.JSON(http.StatusCreated, content)
}
κ·Έλ°λ° Swagger λ₯Ό μν μ£Όμμλ
ν΄λΉ λ΄μ© (Query param μ λ°λΌ Request body λ‘ μ¬μ©ν struct κ° λ¬λΌμ§) μ κΈ°μ¬ν μκ° μλ κ²μΌλ‘ 보μ
λλ€.
...
// @Param registeringMethod query string true "registerWithInfo or registerWithId"
// @Param nsId path string true "Namespace ID"
// @Param imageInfo body mcir.TbImageInfo true "Details for an image object"
...
ν΄κ²°μ± μΌλ‘λ
/:nsId/resources/image?action=registerWithInfo/:nsId/resources/image?action=registerWithIdμ΄λ κ² κ΅¬λΆλμ΄ μλ κ²μ
/:nsId/resources/registerImageWithInfo/:nsId/resources/registerImageWithIdμ΄λ° μμΌλ‘ λΆλ¦¬νλ μμ΄ μμ΅λλ€.
(REST API μ URL μ΄ μΌλ°μ μΈ REST API tradition κ³Ό λ§μ§ μκΈ°λ ν©λλ€.)
Issue-Label Bot is automatically applying the label bug to this issue, with a confidence of 0.54. Please mark this comment with :thumbsup: or :thumbsdown: to give our bot feedback!
Links: app homepage, dashboard and code for this bot.
@jihoon-seo μλμ κ°μ λ°©μμΌλ‘ μ²λ¦¬νλ©΄ μ΄λ¨κΉμ?
λ€λ§, response λ 쿼리 νλΌλ―Έν°μ λ°λΌ λ€λ₯΄κ² νλ κ²μ λλμ§ λͺ¨λ₯΄κ² μ΅λλ€.
// PostNs godoc
// @Summary Create namespace
// @Description Create namespace by json RestPostNs
// @Tags Namespace
// @Accept json
// @Produce json
(μκΈ°) // @Param registerWithInfo body common.NsInfo true "Post Ns2"
(μκΈ°) // @Param registerWithId body common.NsInfo true "Post Ns"
// @Success 200 {object} common.NsInfo
// @Failure 404 {object} common.SimpleMsg
// @Failure 500 {object} common.SimpleMsg
// @Router /ns [post]

@seokho-son
μ΄ λ°©λ²λ μ’μ κ² κ°μ΅λλ€.
μ΄λ κ² μ§ννκ² μ΅λλ€.
echo-swagger μ© comment μ
// @Router /ns/{nsId}/resources/image?action={registeringMethod} [post]
μμ κ°μ΄ query param μ¬μ©λ²μ λͺ
μμ μΌλ‘ μ μ΄ μ£Όκ³ μΆμλλ°
μ΄λ κ² νλ©΄
swag i
2020/07/07 15:50:42 ParseComment error in file api/rest/server/mcir/image.go :can not parse router comment "/ns/{nsId}/resources/image?action={registeringMethod} [post]"
μ΄λ° μλ¬κ° λ©λλ€.
λ°λΌμ
// @Router /ns/{nsId}/resources/image [post]
μ΄λ κ² μ μ΄μΌ ν©λλ€. (query param μ¬μ©λ²μ λͺ
μμ μΌλ‘ μ μ΄ μ€ μ μμ)
@jihoon-seo μλ λ°©μμ ν΅ν΄μ μ²λ¦¬ν μ μμ κ² κ°μ΅λλ€.
https://github.com/cloud-barista/cb-tumblebug/discussions/414#discussioncomment-546987
mcis get action κ΄λ ¨ API νλΌλ―Έν°λ μ²λ¦¬κ° λ κ² κ°μλ°,
MCIR μͺ½λ ν λ² νμΈν΄λ΄μ£Όμ€ μ μμκΉμ? μ²λ¦¬κ° λμ΄ μλ€λ©΄ ~ ν΄λΉ μ΄μλ close νλ©΄λ κ±° κ°μ΅λλ€.. ^^
/close