@@ -52,8 +52,15 @@ func (handler *AccountHandler) CreateAccount(i any, c *fiber.Ctx) error {
5252
5353 logger , tracer , _ , metricFactory := libCommons .NewTrackingFromContext (ctx )
5454
55- organizationID := c .Locals ("organization_id" ).(uuid.UUID )
56- ledgerID := c .Locals ("ledger_id" ).(uuid.UUID )
55+ organizationID , err := http .GetUUIDFromLocals (c , "organization_id" )
56+ if err != nil {
57+ return http .WithError (c , err )
58+ }
59+
60+ ledgerID , err := http .GetUUIDFromLocals (c , "ledger_id" )
61+ if err != nil {
62+ return http .WithError (c , err )
63+ }
5764
5865 payload := i .(* mmodel.CreateAccountInput )
5966 portfolioID := payload .PortfolioID
@@ -123,8 +130,15 @@ func (handler *AccountHandler) GetAllAccounts(c *fiber.Ctx) error {
123130 ctx , span := tracer .Start (ctx , "handler.get_all_accounts" )
124131 defer span .End ()
125132
126- organizationID := c .Locals ("organization_id" ).(uuid.UUID )
127- ledgerID := c .Locals ("ledger_id" ).(uuid.UUID )
133+ organizationID , err := http .GetUUIDFromLocals (c , "organization_id" )
134+ if err != nil {
135+ return http .WithError (c , err )
136+ }
137+
138+ ledgerID , err := http .GetUUIDFromLocals (c , "ledger_id" )
139+ if err != nil {
140+ return http .WithError (c , err )
141+ }
128142
129143 var (
130144 portfolioID * uuid.UUID
@@ -227,9 +241,20 @@ func (handler *AccountHandler) GetAccountByID(c *fiber.Ctx) error {
227241 ctx , span := tracer .Start (ctx , "handler.get_account_by_id" )
228242 defer span .End ()
229243
230- organizationID := c .Locals ("organization_id" ).(uuid.UUID )
231- ledgerID := c .Locals ("ledger_id" ).(uuid.UUID )
232- id := c .Locals ("id" ).(uuid.UUID )
244+ organizationID , err := http .GetUUIDFromLocals (c , "organization_id" )
245+ if err != nil {
246+ return http .WithError (c , err )
247+ }
248+
249+ ledgerID , err := http .GetUUIDFromLocals (c , "ledger_id" )
250+ if err != nil {
251+ return http .WithError (c , err )
252+ }
253+
254+ id , err := http .GetUUIDFromLocals (c , "id" )
255+ if err != nil {
256+ return http .WithError (c , err )
257+ }
233258
234259 logger .Log (ctx , libLog .LevelInfo , fmt .Sprintf ("Initiating retrieval of Account with Account ID: %s" , id .String ()))
235260
@@ -272,8 +297,16 @@ func (handler *AccountHandler) GetAccountExternalByCode(c *fiber.Ctx) error {
272297 ctx , span := tracer .Start (ctx , "handler.get_account_external_by_code" )
273298 defer span .End ()
274299
275- organizationID := c .Locals ("organization_id" ).(uuid.UUID )
276- ledgerID := c .Locals ("ledger_id" ).(uuid.UUID )
300+ organizationID , err := http .GetUUIDFromLocals (c , "organization_id" )
301+ if err != nil {
302+ return http .WithError (c , err )
303+ }
304+
305+ ledgerID , err := http .GetUUIDFromLocals (c , "ledger_id" )
306+ if err != nil {
307+ return http .WithError (c , err )
308+ }
309+
277310 code := c .Params ("code" )
278311
279312 alias := constant .DefaultExternalAccountAliasPrefix + code
@@ -319,8 +352,16 @@ func (handler *AccountHandler) GetAccountByAlias(c *fiber.Ctx) error {
319352 ctx , span := tracer .Start (ctx , "handler.get_account_by_alias" )
320353 defer span .End ()
321354
322- organizationID := c .Locals ("organization_id" ).(uuid.UUID )
323- ledgerID := c .Locals ("ledger_id" ).(uuid.UUID )
355+ organizationID , err := http .GetUUIDFromLocals (c , "organization_id" )
356+ if err != nil {
357+ return http .WithError (c , err )
358+ }
359+
360+ ledgerID , err := http .GetUUIDFromLocals (c , "ledger_id" )
361+ if err != nil {
362+ return http .WithError (c , err )
363+ }
364+
324365 alias := c .Params ("alias" )
325366
326367 logger .Log (ctx , libLog .LevelInfo , fmt .Sprintf ("Initiating retrieval of Account with Account Alias: %s" , alias ))
@@ -368,9 +409,20 @@ func (handler *AccountHandler) UpdateAccount(i any, c *fiber.Ctx) error {
368409 ctx , span := tracer .Start (ctx , "handler.update_account" )
369410 defer span .End ()
370411
371- organizationID := c .Locals ("organization_id" ).(uuid.UUID )
372- ledgerID := c .Locals ("ledger_id" ).(uuid.UUID )
373- id := c .Locals ("id" ).(uuid.UUID )
412+ organizationID , err := http .GetUUIDFromLocals (c , "organization_id" )
413+ if err != nil {
414+ return http .WithError (c , err )
415+ }
416+
417+ ledgerID , err := http .GetUUIDFromLocals (c , "ledger_id" )
418+ if err != nil {
419+ return http .WithError (c , err )
420+ }
421+
422+ id , err := http .GetUUIDFromLocals (c , "id" )
423+ if err != nil {
424+ return http .WithError (c , err )
425+ }
374426
375427 logger .Log (ctx , libLog .LevelInfo , fmt .Sprintf ("Initiating update of Account with ID: %s" , id .String ()))
376428
@@ -426,9 +478,21 @@ func (handler *AccountHandler) DeleteAccountByID(c *fiber.Ctx) error {
426478 ctx , span := tracer .Start (ctx , "handler.delete_account_by_id" )
427479 defer span .End ()
428480
429- organizationID := c .Locals ("organization_id" ).(uuid.UUID )
430- ledgerID := c .Locals ("ledger_id" ).(uuid.UUID )
431- id := c .Locals ("id" ).(uuid.UUID )
481+ organizationID , err := http .GetUUIDFromLocals (c , "organization_id" )
482+ if err != nil {
483+ return http .WithError (c , err )
484+ }
485+
486+ ledgerID , err := http .GetUUIDFromLocals (c , "ledger_id" )
487+ if err != nil {
488+ return http .WithError (c , err )
489+ }
490+
491+ id , err := http .GetUUIDFromLocals (c , "id" )
492+ if err != nil {
493+ return http .WithError (c , err )
494+ }
495+
432496 token := c .Get ("Authorization" )
433497
434498 logger .Log (ctx , libLog .LevelInfo , fmt .Sprintf ("Initiating removal of Account with ID: %s" , id .String ()))
@@ -469,8 +533,15 @@ func (handler *AccountHandler) CountAccounts(c *fiber.Ctx) error {
469533 ctx , span := tracer .Start (ctx , "handler.count_accounts" )
470534 defer span .End ()
471535
472- organizationID := c .Locals ("organization_id" ).(uuid.UUID )
473- ledgerID := c .Locals ("ledger_id" ).(uuid.UUID )
536+ organizationID , err := http .GetUUIDFromLocals (c , "organization_id" )
537+ if err != nil {
538+ return http .WithError (c , err )
539+ }
540+
541+ ledgerID , err := http .GetUUIDFromLocals (c , "ledger_id" )
542+ if err != nil {
543+ return http .WithError (c , err )
544+ }
474545
475546 logger .Log (ctx , libLog .LevelInfo , fmt .Sprintf ("Counting accounts for organization %s and ledger %s" , organizationID , ledgerID ))
476547
0 commit comments