Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 8743959

Browse files
author
Andrea De Pirro
committed
Laravel request accept json middleware
0 parents commit 8743959

File tree

14 files changed

+302
-0
lines changed

14 files changed

+302
-0
lines changed

‎.gitignore‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/vendor/
2+
composer.lock
3+
.php_cs.cache

‎.php_cs‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
$finder = PhpCsFixer\Finder::create()
3+
->in(__DIR__.'/src')
4+
->in(__DIR__.'/tests')
5+
;
6+
return PhpCsFixer\Config::create()
7+
->setRules([
8+
'@PSR2' => true,
9+
'array_syntax' => ['syntax' => 'short'],
10+
'concat_space' => ['spacing' => 'one'],
11+
'new_with_braces' => true,
12+
'no_blank_lines_after_phpdoc' => true,
13+
'no_empty_phpdoc' => true,
14+
'no_empty_comment' => true,
15+
'no_leading_import_slash' => true,
16+
'no_trailing_comma_in_singleline_array' => true,
17+
'no_unused_imports' => true,
18+
'ordered_imports' => ['importsOrder' => null, 'sortAlgorithm' => 'alpha'],
19+
'phpdoc_add_missing_param_annotation' => ['only_untyped' => true],
20+
'phpdoc_align' => true,
21+
'phpdoc_no_empty_return' => true,
22+
'phpdoc_order' => true,
23+
'phpdoc_scalar' => true,
24+
'phpdoc_to_comment' => true,
25+
'psr0' => false,
26+
'psr4' => true,
27+
'return_type_declaration' => ['space_before' => 'none'],
28+
'single_blank_line_before_namespace' => true,
29+
'single_quote' => true,
30+
'space_after_semicolon' => true,
31+
'ternary_operator_spaces' => true,
32+
'trailing_comma_in_multiline_array' => true,
33+
'trim_array_spaces' => true,
34+
'whitespace_after_comma_in_array' => true,
35+
])
36+
->setFinder($finder)
37+
;

‎.phpunit.result.cache‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
C:37:"PHPUnit\Runner\DefaultTestResultCache":333:{a:2:{s:7:"defects";a:1:{s:84:"Softonic\RequestContentDecompress\Tests\Middleware\RequestAcceptJsonTest::testHandle";i:4;}s:5:"times";a:2:{s:84:"Softonic\RequestContentDecompress\Tests\Middleware\RequestAcceptJsonTest::testHandle";d:0.196;s:77:"Softonic\RequestAcceptJson\Tests\Middleware\RequestAcceptJsonTest::testHandle";d:0.104;}}}

‎.scrutinizer.yml‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
filter:
2+
paths: [src/*]
3+
excluded_paths: [tests/*]
4+
checks:
5+
php:
6+
code_rating: true
7+
tools:
8+
external_code_coverage:
9+
timeout: 600
10+
runs: 2
11+
php_code_coverage: false
12+
php_loc:
13+
enabled: true
14+
excluded_dirs: [tests, vendor]
15+
php_cpd:
16+
enabled: true
17+
excluded_dirs: [tests, vendor]

‎.travis.yml‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
language: php
2+
3+
sudo: false
4+
5+
matrix:
6+
include:
7+
- php: 7.1
8+
env: COLLECT_COVERAGE=true VALIDATE_CODING_STYLE=true
9+
- php: 7.2
10+
env: COLLECT_COVERAGE=true VALIDATE_CODING_STYLE=true
11+
- php: 7.3
12+
env: COLLECT_COVERAGE=true VALIDATE_CODING_STYLE=true
13+
- php: master
14+
env: COLLECT_COVERAGE=true VALIDATE_CODING_STYLE=false
15+
allow_failures:
16+
- php: master
17+
fast_finish: true
18+
19+
cache:
20+
directories:
21+
- $HOME/.composer/cache
22+
23+
before_install:
24+
- travis_retry composer self-update
25+
26+
install:
27+
- travis_retry composer update --no-interaction --prefer-source
28+
29+
script:
30+
- composer phpunit
31+
32+
after_script:
33+
- if [ "$COLLECT_COVERAGE" == "true" ]; then wget https://scrutinizer-ci.com/ocular.phar && php ocular.phar code-coverage:upload --format=php-clover build/clover.xml; fi
34+
- if [ "$VALIDATE_CODING_STYLE" == "true" ]; then composer phpcs; fi

‎CODEOWNERS‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @akira28 @joskfg

‎LICENSE‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Copyright 2019 Softonic International S.A.
2+
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.

‎README.md‎

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
Laravel request accept json middleware
2+
=====
3+
4+
[![Latest Version](https://img.shields.io/github/release/softonic/laravel-request-accept-json-middleware.svg?style=flat-square)](https://github.com/softonic/laravel-request-accept-json-middleware/releases)
5+
[![Software License](https://img.shields.io/badge/license-Apache%202.0-blue.svg?style=flat-square)](LICENSE.md)
6+
[![Build Status](https://img.shields.io/travis/softonic/laravel-request-accept-json-middleware/master.svg?style=flat-square)](https://travis-ci.org/softonic/laravel-request-accept-json-middleware)
7+
[![Coverage Status](https://img.shields.io/scrutinizer/coverage/g/softonic/laravel-request-accept-json-middleware.svg?style=flat-square)](https://scrutinizer-ci.com/g/softonic/laravel-request-accept-json-middleware/code-structure)
8+
[![Quality Score](https://img.shields.io/scrutinizer/g/softonic/laravel-request-accept-json-middleware.svg?style=flat-square)](https://scrutinizer-ci.com/g/softonic/laravel-request-accept-json-middleware)
9+
[![Total Downloads](https://img.shields.io/packagist/dt/softonic/laravel-request-accept-json-middleware.svg?style=flat-square)](https://packagist.org/packages/softonic/laravel-request-accept-json-middleware)
10+
11+
This middleware adds the ability to automatically add the Accept application/json header to every request
12+
13+
Installation
14+
-------
15+
16+
Via composer:
17+
```
18+
composer require softonic/laravel-request-accept-json-middleware
19+
```
20+
21+
Documentation
22+
-------
23+
24+
To use the middleware register it in `app/Http/Kernel.php`
25+
26+
```
27+
protected $middleware
28+
= [
29+
...
30+
RequestAcceptJson::class,
31+
...
32+
];
33+
```
34+
35+
From now on the header `Accept: application/json` will be automatically added to every request.
36+
37+
Testing
38+
-------
39+
40+
`softonic/laravel-request-accept-json-middleware` has a [PHPUnit](https://phpunit.de) test suite and a coding style compliance test suite using [PHP CS Fixer](http://cs.sensiolabs.org/).
41+
42+
To run the tests, run the following command from the project folder.
43+
44+
``` bash
45+
$ docker-compose run tests
46+
```
47+
48+
To run interactively using [PsySH](http://psysh.org/):
49+
``` bash
50+
$ docker-compose run psysh
51+
```
52+
53+
License
54+
-------
55+
56+
The Apache 2.0 license. Please see [LICENSE](LICENSE) for more information.
57+
58+
[PSR-2]: http://www.php-fig.org/psr/psr-2/
59+
[PSR-4]: http://www.php-fig.org/psr/psr-4/

‎build/.gitignore‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*
2+
!.gitignore

‎composer.json‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"name": "softonic/laravel-request-accept-json-middleware",
3+
"type": "library",
4+
"description": "Laravel middleware to add accept application/json to requests",
5+
"keywords": ["json", "request", "middleware", "laravel"],
6+
"license": "Apache-2.0",
7+
"homepage": "https://github.com/softonic/laravel-request-accept-json-middleware",
8+
"support": {
9+
"issues": "https://github.com/softonic/laravel-request-accept-json-middleware/issues"
10+
},
11+
"require": {
12+
"php": ">=7.2",
13+
"illuminate/http": "^5.8",
14+
"illuminate/contracts": "^5.8"
15+
},
16+
"require-dev": {
17+
"mockery/mockery": "^1.2",
18+
"phpunit/phpunit": "^8.0",
19+
"friendsofphp/php-cs-fixer": "^2.4"
20+
},
21+
"autoload": {
22+
"psr-4": {
23+
"Softonic\\RequestAcceptJson\\": "src/"
24+
}
25+
},
26+
"autoload-dev": {
27+
"psr-4": {
28+
"Softonic\\RequestAcceptJson\\Tests\\": "tests/"
29+
}
30+
},
31+
"scripts": {
32+
"tests": "phpunit --coverage-text; php-cs-fixer fix -v --diff --dry-run --allow-risky=yes;",
33+
"phpunit": "phpunit --coverage-text",
34+
"phpcs": "php-cs-fixer fix -v --diff --dry-run --allow-risky=yes;",
35+
"fix-cs": "php-cs-fixer fix -v --diff --allow-risky=yes;"
36+
}
37+
}
38+

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /