diff --git a/app/Http/Controllers/Api/V1/SiteController.php b/app/Http/Controllers/Api/V1/SiteController.php index 089d127..85d9bd8 100644 --- a/app/Http/Controllers/Api/V1/SiteController.php +++ b/app/Http/Controllers/Api/V1/SiteController.php @@ -34,7 +34,7 @@ public function register(SiteRequest $request): JsonResponse $url = $request->string('url'); $key = $request->string('key'); - $connectionService = App::makeWith(Connection::class, [$url, $key]); + $connectionService = App::makeWith(Connection::class, ["baseUrl" => $url, "key" => $key]); // Do a health check try { @@ -49,7 +49,7 @@ public function register(SiteRequest $request): JsonResponse $site = new Site(); $site->key = $key; - $site->url = $url; + $site->url = rtrim($url, "/"); $site->last_seen = Carbon::now(); // Fill with site info diff --git a/app/RemoteSite/Connection.php b/app/RemoteSite/Connection.php index 7b2cab7..e4fa96f 100644 --- a/app/RemoteSite/Connection.php +++ b/app/RemoteSite/Connection.php @@ -67,15 +67,13 @@ public function performExtractionRequest(array $requestData): array ] ); - $responseData = $this->decodeResponse($response, $request); - - return $responseData; + return $this->decodeResponse($response, $request); } protected function performWebserviceRequest( HttpMethod $method, string $endpoint, - array $requestData = [] + ?array $requestData = null ): array { $request = new Request( $method->name, @@ -89,7 +87,11 @@ protected function performWebserviceRequest( $response = $this->performHttpRequest( $request, [ - "json" => $requestData + "json" => $requestData, + "headers" => [ + "Content-Type" => "application/json", + "Accept" => "application/vnd.api+json" + ] ] );