예제 #1
0
<?php

use App\Controllers\UsuarioController;
use App\Config\Response;
$app->group('/usuarios', function () {
    $usuario = new UsuarioController();
    $token = new Response();
    $this->get('/', function ($request, $response, $args) use($usuario, $token) {
        $resp = $token->Token($request);
        if ($resp['api_key'] === true) {
            $resp = $usuario->Get();
        }
        return $response->withStatus($resp['status'])->withJson($resp['mensaje']);
    });
    $this->get('/{id}', function ($request, $response, $args) use($usuario, $token) {
        $resp = $token->Token($request);
        if ($resp['api_key'] === true) {
            $resp = $usuario->BuscarPorId($args['id']);
        }
        return $response->withStatus($resp['status'])->withJson($resp['mensaje']);
    });
    $this->get('/filtrar/', function ($request, $response, $args) use($usuario, $token) {
        $resp = $token->Token($request);
        if ($resp['api_key'] === true) {
            $resp = $usuario->BuscarPorLike($request);
        }
        return $response->withStatus($resp['status'])->withJson($resp['mensaje']);
    });
    $this->get('/listar/', function ($request, $response, $args) use($usuario, $token) {
        $resp = $token->Token($request);
        if ($resp['api_key'] === true) {
예제 #2
0
<?php

use App\Controllers\SecurityController;
use App\Config\Response;
$security = new SecurityController();
$api = new Response();
$app->post('/security/access_token', function ($request, $response, $args) use($security, $api) {
    $resp = $api->LoginApiKey($request);
    if ($resp['api_key'] === true) {
        $resp = $security->Token($request->getParsedBody());
    }
    return $response->withStatus($resp['status'])->withJson($resp['mensaje']);
});