diff --git a/src/XmlRequestMiddleware.php b/src/XmlRequestMiddleware.php index 7e1dfba..678eafd 100644 --- a/src/XmlRequestMiddleware.php +++ b/src/XmlRequestMiddleware.php @@ -4,19 +4,26 @@ use Closure; +/** + * Class XmlRequestMiddleware + * @package XmlMiddleware + */ class XmlRequestMiddleware { /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request - * @param \Closure $next + * @param \Closure $next + * * @return mixed */ public function handle($request, Closure $next) { - $request->merge($request->xml()); - + // We pass an array to merge if the xml parsing somewhat failed, no error will trigger + // If the xml request contains an empty body + $request->merge($request->xml() ?: []); + return $next($request); } } \ No newline at end of file