39 lines
603 B
Go
39 lines
603 B
Go
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)
|
|
}
|