Skip to content

Commit 46db52e

Browse files
authored
PR #89 & #88 [asm89/stack-cors#89] (#90)
* PR #89 & #88 [asm89/stack-cors#89] * Necessary corrections.
1 parent 38607ec commit 46db52e

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

README.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ This package can be used as a library or as [stack middleware].
2222

2323
| Option | Description | Default value |
2424
|------------------------|------------------------------------------------------------|---------------|
25-
| allowedMethods | Matches the request method. | `array()` |
26-
| allowedOrigins | Matches the request origin. | `array()` |
27-
| allowedOriginsPatterns | Matches the request origin with `preg_match`. | `array()` |
28-
| allowedHeaders | Sets the Access-Control-Allow-Headers response header. | `array()` |
25+
| allowedMethods | Matches the request method. | `[]` |
26+
| allowedOrigins | Matches the request origin. | `[]` |
27+
| allowedOriginsPatterns | Matches the request origin with `preg_match`. | `[]` |
28+
| allowedHeaders | Sets the Access-Control-Allow-Headers response header. | `[]` |
2929
| exposedHeaders | Sets the Access-Control-Expose-Headers response header. | `false` |
3030
| maxAge | Sets the Access-Control-Max-Age response header. | `false` |
3131
| supportsCredentials | Sets the Access-Control-Allow-Credentials header. | `false` |
@@ -34,7 +34,7 @@ The _allowedMethods_ and _allowedHeaders_ options are case-insensitive.
3434

3535
You don't need to provide both _allowedOrigins_ and _allowedOriginsPatterns_. If one of the strings passed matches, it is considered a valid origin.
3636

37-
If `array('*')` is provided to _allowedMethods_, _allowedOrigins_ or _allowedHeaders_ all methods / origins / headers are allowed.
37+
If `['*']` is provided to _allowedMethods_, _allowedOrigins_ or _allowedHeaders_ all methods / origins / headers are allowed.
3838

3939
### Example: using the library
4040

@@ -43,15 +43,15 @@ If `array('*')` is provided to _allowedMethods_, _allowedOrigins_ or _allowedHea
4343

4444
use Asm89\Stack\CorsService;
4545

46-
$cors = new CorsService(array(
47-
'allowedHeaders' => array('x-allowed-header', 'x-other-allowed-header'),
48-
'allowedMethods' => array('DELETE', 'GET', 'POST', 'PUT'),
49-
'allowedOrigins' => array('http://localhost'),
50-
'allowedOriginsPatterns' => array('/localhost:\d/'),
46+
$cors = new CorsService([
47+
'allowedHeaders' => ['x-allowed-header', 'x-other-allowed-header'],
48+
'allowedMethods' => ['DELETE', 'GET', 'POST', 'PUT'],
49+
'allowedOrigins' => ['http://localhost'],
50+
'allowedOriginsPatterns' => ['/localhost:\d/'],
5151
'exposedHeaders' => false,
5252
'maxAge' => false,
5353
'supportsCredentials' => false,
54-
));
54+
]);
5555

5656
$cors->addActualRequestHeaders(Response $response, $origin);
5757
$cors->handlePreflightRequest(Request $request);
@@ -67,17 +67,17 @@ $cors->isPreflightRequest(Request $request);
6767

6868
use Asm89\Stack\Cors;
6969

70-
$app = new Cors($app, array(
71-
// you can use array('*') to allow any headers
72-
'allowedHeaders' => array('x-allowed-header', 'x-other-allowed-header'),
70+
$app = new Cors($app, [
71+
// you can use ['*'] to allow any headers
72+
'allowedHeaders' => ['x-allowed-header', 'x-other-allowed-header'],
7373
// you can use array('*') to allow any methods
74-
'allowedMethods' => array('DELETE', 'GET', 'POST', 'PUT'),
74+
'allowedMethods' => ['DELETE', 'GET', 'POST', 'PUT'],
7575
// you can use array('*') to allow requests from any origin
76-
'allowedOrigins' => array('localhost'),
76+
'allowedOrigins' => ['localhost'],
7777
// you can enter regexes that are matched to the origin request header
78-
'allowedOriginsPatterns' => array('/localhost:\d/'),
78+
'allowedOriginsPatterns' => ['/localhost:\d/'],
7979
'exposedHeaders' => false,
8080
'maxAge' => false,
8181
'supportsCredentials' => false,
82-
));
82+
]);
8383
```

0 commit comments

Comments
 (0)