{"action":"closed","issue":{"url":"https://api.github.com/repos/zendframework/zend-expressive/issues/236","labels_url":"https://api.github.com/repos/zendframework/zend-expressive/issues/236/labels{/name}","comments_url":"https://api.github.com/repos/zendframework/zend-expressive/issues/236/comments","events_url":"https://api.github.com/repos/zendframework/zend-expressive/issues/236/events","html_url":"https://github.com/zendframework/zend-expressive/issues/236","id":123301545,"number":236,"title":"How to redirect to a given middleware?","user":{"login":"bakura10","id":1198915,"avatar_url":"https://avatars.githubusercontent.com/u/1198915?v=3","gravatar_id":"","url":"https://api.github.com/users/bakura10","html_url":"https://github.com/bakura10","followers_url":"https://api.github.com/users/bakura10/followers","following_url":"https://api.github.com/users/bakura10/following{/other_user}","gists_url":"https://api.github.com/users/bakura10/gists{/gist_id}","starred_url":"https://api.github.com/users/bakura10/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bakura10/subscriptions","organizations_url":"https://api.github.com/users/bakura10/orgs","repos_url":"https://api.github.com/users/bakura10/repos","events_url":"https://api.github.com/users/bakura10/events{/privacy}","received_events_url":"https://api.github.com/users/bakura10/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/zendframework/zend-expressive/labels/question","name":"question","color":"cc317c"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-12-21T15:44:21Z","updated_at":"2015-12-21T15:56:04Z","closed_at":"2015-12-21T15:56:04Z","body":"Hi,\r\n\r\n@weierophinney this is the issue I was talking about on Twitter, but maybe it is better here.\r\n\r\nI want to create a middleware that is used with Elastic Beanstalk SQS worker. Elastic Beanstalk is an AWS service that allows to deploy applications easily, and they also have an environment type called \"worker\".\r\n\r\nThis type of environment fetches messages from a SQS queue, and then does a POST request to a URL of our choice in our application, with the message info.\r\n\r\nWhat I'd like to do is creating a small abstraction layer around this, so that I can push messages in my application:\r\n\r\n```php\r\n$queue->push('my-job-name', ['user_id' => 2, 'other-info' => 'bar']);\r\n```\r\n\r\nOnce read by the worker, it can be configured to do a POST to \"/worker\" URL for instance.\r\n\r\nMy idea is that I'd like to use a mapping between the name of the job, to a given middleware. Therefore, I'd like to be able to create a \"WorkerMiddleware\" (that will be configured on the path I've configured Elastic Beanstalk), and that this middleware would read the \"job name\" (in my example \"my-job-name\"), and match it to a middleware, and then automatically dispatch to this middleware.\r\n\r\nI have thought of two solutions:\r\n\r\n## Inject the container\r\n\r\nThe first idea is to inject the container inside this middleware, so I can retrieve the dependant middleware and call it (or add it to the pipe ?).\r\n\r\n## Pre-routing\r\n\r\nThe other idea I had is to add a pre-routing middleware that will dynamically change the request path, so that when the \"routes\" are fetched, it will actually dispatch to the proper middleware.\r\n\r\n\r\nIs there any other solution for this problem? (yes, I'm basically looking for something similar to the ->forward() controller helper we had in ZF1 :o)"}}