palanik / lumen-cors

CORS Middleware for Lumen micro-framework
MIT License
101 stars 31 forks source link

Changing ->header() to ->headers->set() #12

Open daiplusplus opened 6 years ago

daiplusplus commented 6 years ago

I recently did a composer update and the old $rsp->header() calls were failing with this error:

Call to undefined method Symfony\Component\HttpFoundation\Response::header()
in LumenCors.php (line 21)
at LumenCors->setOrigin(object(Request), object(Response))in LumenCors.php (line 86)
at LumenCors->setCorsHeaders(object(Request), object(Response))in LumenCors.php (line 108)
at LumenCors->handle(object(Request), object(Closure))in Pipeline.php (line 148)
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request))in Pipeline.php (line 32)
at Pipeline->Laravel\Lumen\Routing\{closure}(object(Request))in Pipeline.php (line 102)
at Pipeline->then(object(Closure))in RoutesRequests.php (line 778)
at Application->sendThroughPipeline(array('palanik\\lumen\\Middleware\\LumenCors'),object(Closure))in RoutesRequests.php (line 534)
at Application->dispatch(null)in RoutesRequests.php (line 475)
at Application->run()in index.php (line 62)

This PR changes it to use $rsp->headers->set() which now works.

I don't know exactly when the breaking change was introduced.