Skip to content

Internal Routes - Passing on content as parameters to internal routes  #902

Open
@wayne5w

Description

@wayne5w

Been pulling my hair out all night on this one. I created a little BatchController for executing rest calls in a group. It utilizes the Internal Routes. It works great on homestead but fails on forge. To use the BatchController I make a post to BatchController.store() and in the body is a json object with multiple routes specified. The store() function pulls the json apart and makes the appropriate internal route calls.

I have narrowed it down. On forge the Request object on the internal route contains parameters equivalent to the the original json object that was sent to the BatchController store() function. On homestead the parameters are properly empty. Below is a snippet of the BatchController. Any help is much appreciated, can't seem to narrow it down anymore. When I dump the dispatcher before making the internal route call it has the json object as content, and no parameters. After making the internal route call if I dump the dispatcher, it has parameters equivalent to the json object.

class BatchController extends AbstractControllerBase
{
    public function store(Request $request) {
        $dispatcher = app('Dingo\Api\Dispatcher');
        $result = [];
        $batchRequests = json_decode($request->getContent());
        $request->replace([]);
        foreach ($batchRequests->requests as $batchRequest) {
            $response = $dispatcher->get($batchRequest->endpoint, []);
            $result = array_add($result, $response);
        }
        return $result;
    }
} 

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions