| 1 | <?php |
||
| 2 | |||
| 3 | namespace Faxity\IP; |
||
| 4 | |||
| 5 | use Anax\Commons\ContainerInjectableInterface; |
||
| 6 | use Anax\Commons\ContainerInjectableTrait; |
||
| 7 | |||
| 8 | /** |
||
| 9 | * Controller for the /ip-api routes |
||
| 10 | */ |
||
| 11 | class APIController implements ContainerInjectableInterface |
||
| 12 | { |
||
| 13 | use ContainerInjectableTrait; |
||
| 14 | |||
| 15 | |||
| 16 | /** |
||
| 17 | * Handles / for the controller |
||
| 18 | * |
||
| 19 | * @return array |
||
| 20 | */ |
||
| 21 | 3 | public function indexActionPost() : array |
|
| 22 | { |
||
| 23 | 3 | $ip = $this->di->request->getPost("ip"); |
|
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 24 | 3 | $res = $this->di->ip->validate($ip); |
|
|
0 ignored issues
–
show
|
|||
| 25 | |||
| 26 | 3 | if (is_null($res)) { |
|
| 27 | 1 | $json = [ "message" => "Ingen IP address skickades." ]; |
|
| 28 | 1 | return [ $json, 400 ]; |
|
| 29 | } |
||
| 30 | |||
| 31 | 2 | return [ (array) $res, 200 ]; |
|
| 32 | } |
||
| 33 | } |
||
| 34 |