laravel 5 - How to set headers for forwarded request -


my controller's methods require header set, e.g. x-authorization. after new object has been created (store action), forward show newly created object (show action):

$request = request::create(route('api.v1.b.show', ['booking' => 4]), 'get'); request::replace($request->input()); return route::dispatch($request); 

the forwarding works ok if disable authorization check, fails otherwise. ie. header has gone. copy request header, can request::header('x-authorization') forwarded request. possible?

i have tried without success $request->header('x-authorization', 'xxxxx'). tried php's header() before dispatch , didn't work.

any ideas? cheers

ok, think need set headers so:

$request = request::create(route('api.v1.b.show', ['booking' => 4]), 'get'); $request->headers->set('x-authorization', 'xxxxx'); 

that answer question.

my question is: can set headers every api request(forwarding)? because have 5 headers set request , don't want repeat myself.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -