Thanks for reading my problem,
I am trying to add middleware to slim framework but it encounter with an error
Uncaught InvalidArgumentException: All Route middleware must be callable
           $authenticateForRole = function ( $user_Id, $tokenKey ) {
                 try {
                     // my stuffs 
                      }
                  } catch (\Throwable $th) {
                      echo $th->getMessage();
                      return false;
                  }
              };
              $app->map('/averageresponsetime/',$authenticateForRole($UserId, $token), function () use ($app) { 
                   echo json_encode($post1);
              })->via('POST');
              $app->run();
 
                        
i think you should use a clousure as the documentation states;