-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #346 from baking-bad/refactoring/tzip
Refactoring/tzip
- Loading branch information
Showing
92 changed files
with
1,704 additions
and
2,809 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package handlers | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/baking-bad/bcdhub/internal/elastic" | ||
"github.com/gin-gonic/gin" | ||
) | ||
|
||
// GetMetadata godoc | ||
// @Summary Get metadata for account | ||
// @Description Returns full metadata for account | ||
// @Tags account | ||
// @ID get-account-tzip | ||
// @Param network path string true "Network" | ||
// @Param address path string true "KT or tz address" minlength(36) maxlength(36) | ||
// @Accept json | ||
// @Produce json | ||
// @Success 200 {object} models.TZIP | ||
// @Success 204 {object} gin.H | ||
// @Failure 400 {object} Error | ||
// @Failure 500 {object} Error | ||
// @Router /account/{network}/{address}/tzip [get] | ||
func (ctx *Context) GetMetadata(c *gin.Context) { | ||
var req getContractRequest | ||
if err := c.BindUri(&req); handleError(c, err, http.StatusBadRequest) { | ||
return | ||
} | ||
tzip, err := ctx.ES.GetTZIP(req.Network, req.Address) | ||
if err != nil { | ||
if elastic.IsRecordNotFound(err) { | ||
c.JSON(http.StatusOK, gin.H{}) | ||
} else { | ||
handleError(c, err, 0) | ||
} | ||
return | ||
} | ||
c.JSON(http.StatusOK, tzip) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.