dogancelik/slim-json — pull request #2 by jwellner (2014-05-06 20:31:19+00:00)
Title: Cors: check origin against a list of allowed hosts

For CORS I wanted to be able to check the request origin on a list of allowed hosts.

I implemented it like this :
```
$app->add(new \SlimJson\Middleware(array(
'json.cors' => function($requestOrigin) {

$allowed = array(
'http://localhost:9000',
'http://www.domain.com',
'http://domain.com'
);

if(in_array($requestOrigin, $allowed)) {
return $requestOrigin;
} else {
return false;
}
},
```
Now when the requestOrigin is in the list of allowed hosts it returns the request origin and shows the 'Access-Control-Allow-Origin' header. If it is not in the allowed hosts list it returns false and skips setting the 'Access-Control-Allow-Origin' header.

This change should be backwards compatible with the old json.cors config.