src/Chiron/Http/Middleware/MethodOverrideMiddleware.php
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        // TODO : on devrait plutot utiliser un truc genre : strtoupper($request->getHeaderLine("X-Http-Method-Override"));
        if ($request->hasHeader('X-Http-Method-Override')) {
            if (! empty($request->getHeader('X-Http-Method-Override')[0])) {
                $request = $request->withMethod($request->getHeader('X-Http-Method-Override')[0]);
            }
        }
        if (strtoupper($request->getMethod()) === 'GET') {
            if (! empty($request->getQueryParams()['_method'])) {
                $method = $request->getQueryParams()['_method'];
                $request = $request->withMethod($method);
            }
        }
        if (strtoupper($request->getMethod()) === 'POST') {
            if (! empty($request->getParsedBody()['_method'])) {
                $request = $request->withMethod($request->getParsedBody()['_method']);
            }
            /*
            if ($request->getBody()->eof()) {
                $request->getBody()->rewind();
            }*/
        }

        // TODO : faire un throw HttpException 405 si la méthode override n'est pas correcte

        $response = $handler->handle($request);

        return $response;
    }
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        // TODO : on devrait plutot utiliser un truc genre : strtoupper($request->getHeaderLine("X-Http-Method-Override"));
        if ($request->hasHeader('X-Http-Method-Override')) {
            if (! empty($request->getHeader('X-Http-Method-Override')[0])) {
                $request = $request->withMethod($request->getHeader('X-Http-Method-Override')[0]);
            }
        }
        if (strtoupper($request->getMethod()) === 'GET') {
            if (! empty($request->getQueryParams()['_method'])) {
                $method = $request->getQueryParams()['_method'];
                $request = $request->withMethod($method);
            }
        }
        if (strtoupper($request->getMethod()) === 'POST') {
            if (! empty($request->getParsedBody()['_method'])) {
                $request = $request->withMethod($request->getParsedBody()['_method']);
            }
            /*
            if ($request->getBody()->eof()) {
                $request->getBody()->rewind();
            }*/
        }

        // TODO : faire un throw HttpException 405 si la méthode override n'est pas correcte

        $response = $handler->handle($request);

        return $response;
    }
public function process ( ServerRequestInterface $ request , RequestHandlerInterface $ handler ) : ResponseInterface { // TODO : on devrait plutot utiliser un truc genre : strtoupper($request->getHeaderLine("X-Http-Method-Override")); if ( $ request -> hasHeader ( 'X-Http-Method-Override' ) ) { if ( ! empty ( $ request -> getHeader ( 'X-Http-Method-Override' ) [ 0 ] ) ) { $ request = $ request -> withMethod ( $ request -> getHeader ( 'X-Http-Method-Override' ) [ 0 ] ) ; } } if ( strtoupper ( $ request -> getMethod ( ) ) === 'GET' ) { if ( ! empty ( $ request -> getQueryParams ( ) [ '_method' ] ) ) { $ method = $ request -> getQueryParams ( ) [ '_method' ] ; $ request = $ request -> withMethod ( $ method ) ; } } if ( strtoupper ( $ request -> getMethod ( ) ) === 'POST' ) { if ( ! empty ( $ request -> getParsedBody ( ) [ '_method' ] ) ) { $ request = $ request -> withMethod ( $ request -> getParsedBody ( ) [ '_method' ] ) ; } /*
            if ($request->getBody()->eof()) {
                $request->getBody()->rewind();
            }*/ } // TODO : faire un throw HttpException 405 si la méthode override n'est pas correcte $ response = $ handler -> handle ( $ request ) ; return $ response ; }
Handle the middleware pipeline call. This calls the next middleware
in the queue and after the rest of the middleware pipeline is done
the response will be sent to the client.

@param RequestInterface  $request
@param ResponseInterface $response
@param callable          $next

@return ResponseInterface
Handle the middleware pipeline call . This calls the next middleware in the queue and after the rest of the middleware pipeline is done the response will be sent to the client .