Prechádzať zdrojové kódy

feat: cookies added to response_call.

yusuke nakazawa 6 rokov pred
rodič
commit
850e4cf8d1

+ 7 - 0
config/apidoc.php

@@ -141,6 +141,13 @@ return [
                         // 'key' => 'value',
                     ],
 
+                    /*
+                     * Cookies which should be sent with the API call.
+                     */
+                    'cookies' => [
+                        // 'name' => 'value'
+                    ],
+
                     /*
                      * Query parameters which should be sent with the API call.
                      */

+ 2 - 1
src/Tools/ResponseStrategies/ResponseCallStrategy.php

@@ -67,7 +67,8 @@ class ResponseCallStrategy
         $uri = $this->replaceUrlParameterBindings($route, $rulesToApply['bindings'] ?? []);
         $routeMethods = $this->getMethods($route);
         $method = array_shift($routeMethods);
-        $request = Request::create($uri, $method, [], [], [], $this->transformHeadersToServerVars($rulesToApply['headers'] ?? []));
+        $cookies = isset($rulesToApply['cookies']) ? $rulesToApply['cookies'] : [];
+        $request = Request::create($uri, $method, [], $cookies, [], $this->transformHeadersToServerVars($rulesToApply['headers'] ?? []));
         $request = $this->addHeaders($request, $route, $rulesToApply['headers'] ?? []);
 
         // Mix in parsed parameters with manually specified parameters.