2020-12-29 13:46:58 +01:00
|
|
|
package handlers
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/gofiber/fiber/v2"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Hello handler
|
2021-01-02 11:56:24 +01:00
|
|
|
func (h Handlers) Hello(c *fiber.Ctx) error {
|
2020-12-29 13:46:58 +01:00
|
|
|
return c.SendString("Hello, World!")
|
|
|
|
}
|
|
|
|
|
2021-01-02 11:56:24 +01:00
|
|
|
// AccountGet handler
|
|
|
|
func (h Handlers) AccountGet(c *fiber.Ctx) error {
|
2021-01-04 16:29:58 +01:00
|
|
|
accountID := c.Params("accountID")
|
|
|
|
// logContext := log.WithFields(log.Fields{"accountID": accountID})
|
|
|
|
|
|
|
|
authErr := h.RequireAdminRoleOrAccountID(c, accountID)
|
|
|
|
if authErr != nil {
|
|
|
|
return c.Status(403).JSON([]ResJSONError{{Error: authErr.Error()}})
|
|
|
|
}
|
|
|
|
|
2021-01-05 16:23:18 +01:00
|
|
|
account, accountErr := h.Db.AccountGet(accountID, "", "")
|
2021-01-04 16:29:58 +01:00
|
|
|
if accountErr != nil {
|
|
|
|
return c.Status(500).JSON([]ResJSONError{{Error: accountErr.Error()}})
|
|
|
|
}
|
|
|
|
|
|
|
|
return c.JSON(account)
|
2020-12-29 13:46:58 +01:00
|
|
|
}
|