【发布时间】:2018-04-18 10:00:20
【问题描述】:
我正在尝试使用 Lumen 和 laravel 实现一个微服务架构
我使用 laravel 5.4 作为 ApiGetway,使用 Lumen 5.4 作为微服务
我在我的 laravel 项目中使用 GuzzleHTTP 6.3 版,试图访问微服务 API,但我收到 500 内部服务器错误
我正在我的本地主机中尝试这个
这就是我提出请求的方式:
public function get_posts(){
try {
$client = new Client(); //GuzzleHttp\Client
$res = $client->request('GET', 'http://localhost/micro/posts_micro_service/public/posts');
if($res->getStatusCode() == "200"){
echo $res->getBody();
}else{
return response()->json(['status',"error"]);
}
} catch (ClientException $e) {
echo Psr7\str($e->getRequest());
echo Psr7\str($e->getResponse());
}
}
我收到此错误:
(1/1) ServerException
Server error: `GET http://localhost/micro/posts_micro_service/public/posts` resulted in a `500 Internal Server Error` response:
<!DOCTYPE html>
<html>
<head>
<meta name="robots" content="noindex,nofollow" />
<style>
(truncated...)
in RequestException.php (line 113)
【问题讨论】:
标签: php laravel-5 microservices guzzle lumen