Skip to content

Commit aaca37b

Browse files
Added documentation
1 parent 8443de9 commit aaca37b

File tree

1 file changed

+36
-2
lines changed

1 file changed

+36
-2
lines changed

README.md

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,40 @@
11
# Moon - HTTP Middleware
22
A very simple HTTP Middleware implementation
33

4-
[![Code Climate](https://codeclimate.com/github/moon-php/logger/badges/gpa.svg)](https://codeclimate.com/github/moon-php/http-middleware) [![Build Status](https://travis-ci.org/moon-php/logger.svg?branch=master)](https://travis-ci.org/moon-php/http-middleware)
4+
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/moon-php/http-middleware/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/moon-php/http-middleware/?branch=master)
5+
[![Code Coverage](https://scrutinizer-ci.com/g/moon-php/http-middleware/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/moon-php/http-middleware/?branch=master)
6+
[![Build Status](https://scrutinizer-ci.com/g/moon-php/http-middleware/badges/build.png?b=master)](https://scrutinizer-ci.com/g/moon-php/http-middleware/build-status/master)
57

6-
## In Development
8+
## Documentation
9+
10+
- Delegate
11+
12+
- InvalidArgumentException
13+
14+
15+
16+
### Delegate
17+
18+
__namespace: Moon\HttpMiddleware\Delegate__
19+
20+
According to the PSR15 proposal :
21+
22+
_The DelegateInterface defines a single method that accepts a request and returns a response._
23+
24+
_The delegate interface must be implemented by any middleware dispatcher that uses middleware implementing MiddlewareInterface._
25+
26+
So i decided to make the **Delegate** a **Middleware Dispatcher** itself.
27+
28+
The object is really simple, it has a constructor that requires an **array of MiddlewareInterface** implementor and a callable to use as **default** response.
29+
30+
The MiddlewareInterface implementor will be directly implemented by the userland and inserted into the array.
31+
32+
$request = new ServerRequestImplementor();
33+
$delegate = new Delegate([new MiddlewareOne(), new MiddlewareTwo(), new MiddlewareThree()], new DefaultResponse());
34+
$delegate->process($request);
35+
36+
### InvalidArgumentException
37+
38+
__namespace Moon\HttpMiddleware\Exception\InvalidArgumentException__
39+
40+
If an object passed into the array is not a MiddlewareInterface implementor and **InvalidArgumentException** will be thrown.

0 commit comments

Comments
 (0)