Skip to content

Commit 2ebdba1

Browse files
committed
added async interface
1 parent 0b0f12f commit 2ebdba1

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed

src/AsyncMiddlewareInterface.hack

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/**
2+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
3+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
4+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
5+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
6+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
7+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
8+
* THE SOFTWARE.
9+
*
10+
* This software consists of voluntary contributions made by many individuals
11+
* and is licensed under the MIT license.
12+
*
13+
* Copyright (c) 2018-2019 Yuuki Takezawa
14+
*
15+
*/
16+
namespace Nazg\Http\Server;
17+
18+
use type HH\Lib\Experimental\IO\WriteHandle;
19+
use type Facebook\Experimental\Http\Message\ResponseInterface;
20+
use type Facebook\Experimental\Http\Message\ServerRequestInterface;
21+
22+
/**
23+
* An HTTP middleware component participates in processing an HTTP message,
24+
* either by acting on the request or the response. This interface defines the
25+
* methods required to use the middleware.
26+
*/
27+
interface AsyncMiddlewareInterface {
28+
29+
public function processAsync(
30+
WriteHandle $writeHandle,
31+
ServerRequestInterface $request,
32+
AsyncRequestHandlerInterface $handler
33+
): Awaitable<ResponseInterface>;
34+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/**
2+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
3+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
4+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
5+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
6+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
7+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
8+
* THE SOFTWARE.
9+
*
10+
* This software consists of voluntary contributions made by many individuals
11+
* and is licensed under the MIT license.
12+
*
13+
* Copyright (c) 2018-2019 Yuuki Takezawa
14+
*
15+
*/
16+
namespace Nazg\Http\Server;
17+
18+
use type HH\Lib\Experimental\IO\WriteHandle;
19+
use type Facebook\Experimental\Http\Message\ResponseInterface;
20+
use type Facebook\Experimental\Http\Message\ServerRequestInterface;
21+
22+
/**
23+
* An HTTP request handler process a HTTP request and produces an HTTP response.
24+
* This interface defines the methods require to use the async request handler.
25+
*/
26+
interface AsyncRequestHandlerInterface {
27+
28+
public function handleAsync(
29+
WriteHandle $writeHandle,
30+
ServerRequestInterface $request
31+
): Awaitable<ResponseInterface>;
32+
}

0 commit comments

Comments
 (0)