2017 © Pedro Peláez
 

library slim-request-time-middleware

Middleware para Slim 3 que agrega cabecera con el tiempo total del request

image

restyphp/slim-request-time-middleware

Middleware para Slim 3 que agrega cabecera con el tiempo total del request

  • Wednesday, April 11, 2018
  • by mostofreddy
  • Repository
  • 0 Watchers
  • 0 Stars
  • 25 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 19 % Grown

The README.md

Deprecated, (*1)

Slim request time middleware

Middleware para Slim 3 que agrega cabecera (Slim-Request-Total-Time) con el tiempo total del request., (*2)

Build Status, (*3)

Versión

0.1.0, (*4)

License

The MIT License (MIT). Ver el archivo LICENSE para más información, (*5)

Documentación

El middleware agrega la cabecera Slim-Request-Total-Time en la respuesta del request con el tiempo total en segundos que tarda el request en procesarse, (*6)

$ curl -v "http://localhost:5005"
* Rebuilt URL to: http://localhost:5005/
*   Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 5005 (#0)
> GET / HTTP/1.1
> Host: localhost:5005
> User-Agent: curl/7.47.0
> Accept: */*
> 
< HTTP/1.1 404 Not Found
< Host: localhost:5005
< Connection: close
< X-Powered-By: PHP/7.0.12
< Content-type: application/json
< Slim-Request-Total-Time: 0.3244
< Content-Length: 200

Ejemplo de uso

Configurar middleware para todas las rutas

require_once "../vendor/autoload.php";

use Slim\App;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Message\ResponseInterface;

$config = [];
$config['settings'] = [
    "displayErrorDetails" => true, // or false
    "determineRouteBeforeAppMiddleware" => true
];

$api = new App($config);

$api->add('\Resty\Slim\TotalTimeRequestMiddleware');

//...

$api->run();

Configurar middleware para alguna ruta (o grupo) en particular

require_once "../vendor/autoload.php";

use Slim\App;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Message\ResponseInterface;

$config = [];
$config['settings'] = [
    "displayErrorDetails" => true, // or false
    "determineRouteBeforeAppMiddleware" => true
];

$api = new App($config);

$api->get('/', function (ServerRequestInterface $request, ResponseInterface $response) {
    $body = $response->getBody();
    $body->write('Hello');
    return $response;
})->add('\Resty\Slim\TotalTimeRequestMiddleware')

$api->run();

The Versions

11/04 2018

dev-master

9999999-dev https://github.com/mostofreddy/slim-request-time-middleware

Middleware para Slim 3 que agrega cabecera con el tiempo total del request

  Sources   Download

MIT

The Requires

  • php >=7.0.0

 

The Development Requires

api middleware log framework rest request time slim

18/01 2017

0.1.0

0.1.0.0 https://github.com/mostofreddy/slim-request-time-middleware

Middleware para Slim 3 que agrega cabecera con el tiempo total del request

  Sources   Download

MIT

The Requires

  • php >=7.0.0

 

The Development Requires

api middleware log framework rest request time slim