MCPcopy Create free account
hub / github.com/devinterface/startersaas-go-api / ByID

Method ByID

endpoints/user.endpoint.go:91–106  ·  view source on GitHub ↗

ByID function

(ctx *fiber.Ctx)

Source from the content-addressed store, hash-verified

89
90// ByID function
91func (userEndpoint *UserEndpoint) ByID(ctx *fiber.Ctx) error {
92 me, _ := userEndpoint.CurrentUser(ctx)
93 if can := userEndpoint.Can(ctx, models.AdminRole); !can {
94 return ctx.Status(401).JSON(fiber.Map{
95 "message": "You are not authorized to perform this action",
96 })
97 }
98 user, err := userService.ByID(ctx.Params("id"), me.AccountID)
99 if err != nil {
100 return ctx.Status(404).JSON(fiber.Map{
101 "message": err.Error(),
102 })
103 }
104 showUser := models.ShowUserSerializer().Transform(user)
105 return ctx.JSON(showUser)
106}
107
108// Index function
109func (userEndpoint *UserEndpoint) Index(ctx *fiber.Ctx) error {

Callers 1

MeMethod · 0.45

Calls 3

ShowUserSerializerFunction · 0.92
CurrentUserMethod · 0.80
CanMethod · 0.80

Tested by

no test coverage detected