add more routes
This commit is contained in:
38
routes/api/user/param_userid/maindeck.go
Normal file
38
routes/api/user/param_userid/maindeck.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package param_userid
|
||||
|
||||
import (
|
||||
"bdgrp_go/db"
|
||||
"bdgrp_go/pbutil"
|
||||
"bdgrp_go/routes"
|
||||
"bdgrp_go/utils"
|
||||
"fmt"
|
||||
|
||||
"github.com/gofiber/fiber/v2"
|
||||
)
|
||||
|
||||
func init() {
|
||||
path := routes.PathOf()
|
||||
routes.Register(func(app *fiber.App) {
|
||||
app.Put(path, mainDeck)
|
||||
fmt.Println("Loaded:", path)
|
||||
})
|
||||
}
|
||||
|
||||
func mainDeck(c *fiber.Ctx) error {
|
||||
decrypted, err := utils.Decrypt(c.Body())
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
|
||||
decoded, err := pbutil.Decode("UserPutRequest", decrypted)
|
||||
|
||||
userid := c.Params("userid")
|
||||
|
||||
user := db.FindUser(userid)
|
||||
|
||||
user["mainDeck"] = decoded["mainDeck"]
|
||||
|
||||
db.Save()
|
||||
|
||||
return c.Send(nil)
|
||||
}
|
||||
Reference in New Issue
Block a user