@@ 21-30 (lines=10) @@ | ||
18 | 'origin' => '*', // Wide Open! |
|
19 | 'allowMethods' => 'GET,HEAD,PUT,POST,DELETE,PATCH,OPTIONS', |
|
20 | ); |
|
21 | protected function setOrigin(Request $req, Response $rsp) { |
|
22 | $origin = $this->settings['origin']; |
|
23 | if (is_callable($origin)) { |
|
24 | // Call origin callback with request origin |
|
25 | $origin = call_user_func($origin, |
|
26 | $req->headers->get("Origin") |
|
27 | ); |
|
28 | } |
|
29 | $rsp->headers->set('Access-Control-Allow-Origin', $origin); |
|
30 | } |
|
31 | protected function setExposeHeaders(Request $req, Response $rsp) { |
|
32 | if (isset($this->settings->exposeHeaders)) { |
|
33 | $exposeHeaders = $this->settings->exposeHeaders; |
|
@@ 51-60 (lines=10) @@ | ||
48 | $rsp->headers->set('Access-Control-Allow-Credentials', 'true'); |
|
49 | } |
|
50 | } |
|
51 | protected function setAllowMethods(Request $req, Response $rsp) { |
|
52 | if (isset($this->settings['allowMethods'])) { |
|
53 | $allowMethods = $this->settings['allowMethods']; |
|
54 | if (is_array($allowMethods)) { |
|
55 | $allowMethods = implode(", ", $allowMethods); |
|
56 | } |
|
57 | ||
58 | $rsp->headers->set('Access-Control-Allow-Methods', $allowMethods); |
|
59 | } |
|
60 | } |
|
61 | protected function setAllowHeaders(Request $req, Response $rsp) { |
|
62 | if (isset($this->settings['allowHeaders'])) { |
|
63 | $allowHeaders = $this->settings['allowHeaders']; |