This repository has been archived by the owner on Jul 25, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Template.php
56 lines (47 loc) · 1.56 KB
/
Template.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
namespace wbadrh\API;
// http://route.thephpleague.com/json-strategy/
// http://route.thephpleague.com/
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
//use League\Route\Http\Exception\NotFoundException;
//use League\Route\Http\Exception\BadRequestException;
/**
* ...
*/
class Template
{
/**
* ...
*
* @param ServerRequestInterface $request Zend Diactoros server request
* @param ResponseInterface $response PSR-7 HTTP response message
* @return Zend\Diactoros\Response $response Manipulated PSR-7 HTTP response message
*/
public function response(ServerRequestInterface $request, ResponseInterface $response)
{
// Demo contents
$contents = 'It works!';
// Write Response to Body
$response->getBody()->write($contents);
// PSR-7 response
return $response;
}
/**
* ...
*
* @param ServerRequestInterface $request Zend Diactoros server request
* @param ResponseInterface $response PSR-7 HTTP response message
* @param Array $args URL query parameters
* @return Zend\Diactoros\Response $response Manipulated PSR-7 HTTP response message
*/
public function response_args(ServerRequestInterface $request, ResponseInterface $response, array $args)
{
// Demo contents
$contents = 'Hello, ' . $args['name'] . '!';
// Write Response to Body
$response->getBody()->write($contents);
// PSR-7 response
return $response;
}
}