# Setting config from middleware

**URL:** <https://discourse.slimframework.com/t/setting-config-from-middleware/1019>\
**Category:** Questions\
**Created:** [December 21, 2016, 3:39pm UTC](https://discourse.slimframework.com/t/setting-config-from-middleware/1019 "2016-12-21T15:39:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nerfair](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/nerfair/32/292_2.png) [@Nerfair](https://discourse.slimframework.com/u/Nerfair)\
**Post date:** [December 21, 2016, 3:39pm UTC](https://discourse.slimframework.com/t/setting-config-from-middleware/1019/1 "2016-12-21T15:39:34Z")

</div>

Hey, i have middleware like this, to authenticate user via JWT, and question is how to modify config array with data stored in $decode variable. Is it possible?

```
    $app->add(
        function (Request $request, Response $response, callable $next) use ($config) {
            $input = $request->getParams();
    
            if (empty($input['token'])) {
                return $response->withStatus(401);
            }
    
            try {
                $decoded = \Firebase\JWT\JWT::decode($input['token'], $config['jwt_key'], ['HS256']);
            } catch (\Exception $e) {
                return $response->withStatus(401);
            }
    
            return $next($request, $response);
        }
    );
```
