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
Post a Comment