1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Copyright (c) 2016-2016 The callingallpapers.com Developer Team |
4
|
|
|
* |
5
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy |
6
|
|
|
* of this software and associated documentation files (the "Software"), to deal |
7
|
|
|
* in the Software without restriction, including without limitation the rights |
8
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
9
|
|
|
* copies of the Software, and to permit persons to whom the Software is |
10
|
|
|
* furnished to do so, subject to the following conditions: |
11
|
|
|
* |
12
|
|
|
* The above copyright notice and this permission notice shall be included in |
13
|
|
|
* all copies or substantial portions of the Software. |
14
|
|
|
* |
15
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
16
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
17
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
18
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
19
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
20
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
21
|
|
|
* THE SOFTWARE. |
22
|
|
|
* |
23
|
|
|
* @author Andreas Heigl<[email protected]> |
24
|
|
|
* @copyright 2016-2016 The callingallpapers.com Developer Team |
25
|
|
|
* @license http://www.opensource.org/licenses/mit-license.php MIT-License |
26
|
|
|
* @version 0.0 |
27
|
|
|
* @since 16.01.2016 |
28
|
|
|
* @link https://github.com/joindin/callingallpapers |
29
|
|
|
*/ |
30
|
|
|
|
31
|
|
|
namespace Callingallpapers\Api\Middleware; |
32
|
|
|
|
33
|
|
|
use Callingallpapers\Api\PersistenceLayer\UserPersistenceLayer; |
34
|
|
|
use Psr\Http\Message\ResponseInterface; |
35
|
|
|
use Psr\Http\Message\ServerRequestInterface; |
36
|
|
|
|
37
|
|
|
class CORS |
38
|
|
|
{ |
39
|
|
|
protected $app; |
40
|
|
|
|
41
|
|
|
public function __construct($app) |
42
|
|
|
{ |
43
|
|
|
$this->app = $app; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* Example middleware invokable class |
48
|
|
|
* |
49
|
|
|
* @param \Psr\Http\Message\ServerRequestInterface $request PSR7 request |
50
|
|
|
* @param \Psr\Http\Message\ResponseInterface $response PSR7 response |
51
|
|
|
* @param callable $next Next middleware |
52
|
|
|
* |
53
|
|
|
* @return \Psr\Http\Message\ResponseInterface |
54
|
|
|
*/ |
55
|
|
|
public function __invoke( |
56
|
|
|
ServerRequestInterface $request, |
57
|
|
|
ResponseInterface $response, |
58
|
|
|
callable $next |
59
|
|
|
) { |
60
|
|
|
$response = $response->withHeader('Access-Control-Allow-Origin', '*'); |
61
|
|
|
|
62
|
|
|
return $next($request, $response); |
63
|
|
|
} |
64
|
|
|
} |
65
|
|
|
|