Skip to content

Commit 6fb7891

Browse files
committed
changes
1 parent 981c4ef commit 6fb7891

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

api/projects/projects.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ func ApplyRoutes(r *gin.RouterGroup) {
2424

2525
func AddProject(c *gin.Context) {
2626
var req AddProjectRequest
27-
if err := c.BindJSON(&req); err != nil {
27+
if err := c.ShouldBind(&req); err != nil {
2828
fmt.Println("error", err)
29+
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
2930
return
3031
}
3132
db := dbconfig.GetDb()
@@ -39,9 +40,11 @@ func AddProject(c *gin.Context) {
3940
project.Twitter = req.Twitter
4041
project.Linkedin = req.Linkedin
4142
project.Owner = req.Owner
43+
project.Image = req.Image
4244
err := db.Create(&project).Error
4345
if err != nil {
4446
fmt.Println("error", err.Error())
47+
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
4548
return
4649
}
4750
c.JSON(http.StatusOK, gin.H{

api/user/types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package user
22

33
type request struct {
4-
username string `json:"username"`
5-
walletAddress string `json:"username"`
4+
Username string `json:"username"`
5+
WalletAddress string `json:"walletAddress"`
66
}

api/user/user.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ func AssignWalletToUsername(c *gin.Context) {
9898
"error": "bad request",
9999
})
100100
}
101-
tx, err := instance.AssignAddressToUsername(auth, request.username, common.HexToAddress(request.walletAddress))
101+
tx, err := instance.AssignAddressToUsername(auth, request.Username, common.HexToAddress(request.WalletAddress))
102102
if err != nil {
103103
logrus.Errorf("cannot assert type: publicKey is not of type *ecdsa.PublicKey")
104104
c.JSON(http.StatusInternalServerError, gin.H{

0 commit comments

Comments
 (0)