PluginProbe
Depicter — Popup & Slider Builder / trunk
Depicter — Popup & Slider Builder vtrunk
4.8.1 trunk 1.0.0 1.1.0 1.1.2 1.1.4 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.3.5 1.3.8 1.5.0 1.5.1 1.5.2 1.5.5 1.6.0 1.6.1 1.6.2 1.7.0 All 76 releases
depicter / app / src / Middleware / CORSMiddleware.php

CORSMiddleware.php in Depicter — Popup & Slider Builder trunk, at app/src/Middleware/CORSMiddleware.php

48 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Depicter\Middleware;
3
4 use WPEmerge\Requests\RequestInterface;
5 use WPEmerge\Responses\ResponseService;
6
7
8 class CORSMiddleware
9 {
10
11 /**
12 * Response service.
13 *
14 * @var ResponseService
15 */
16 protected $responseService = null;
17
18 /**
19 * Constructor.
20 *
21 * @codeCoverageIgnore
22 * @param ResponseService $responseService
23 */
24 public function __construct( ResponseService $responseService ) {
25 $this->responseService = $responseService;
26 }
27
28 /**
29 * @param RequestInterface $request
30 * @param $next
31 *
32 * @return \Psr\Http\Message\ResponseInterface
33 */
34 public function handle( RequestInterface $request, $next ) {
35
36 //return $this->responseService->json( $result )->withHeader('Cache-Control', 'max-age=' . $expiration );
37
38 $response = $next( $request );
39
40 $response->withHeader('Access-Control-Allow-Origin' , '*');
41 $response->withHeader('Access-Control-Allow-Methods', 'POST, GET, OPTIONS, PUT, DELETE');
42 $response->withHeader('Access-Control-Allow-Headers', 'Content-Type, Accept, Authorization, X-Requested-With, Application');
43
44 return $response;
45 }
46
47 }
48