Я пытаюсь создать простой API в люмен, все работало нормально, пока я не обновил пакет composer.Теперь я не могу получить Json от любого запроса.
private $request;
public function __construct(Request $request) {
$this->request = $request;
}
protected function jwt(User $user) {
$payload = [
'iss' => "lumen-jwt", // Issuer of the token
'sub' => $user->id, // Subject of the token
'iat' => time(), // Time when JWT was issued.
'exp' => time() + 60*60 // Expiration time
];
return JWT::encode($payload, env('JWT_SECRET'));
}
public function authenticate(User $user) {
dd($this->request->content);
$this->validate($this->request, [
'email' => 'required|email',
'password' => 'required'
]);
// Find the user by email
$user = User::where('email', $this->request->input('email'))->first();
if (!$user) {
// You wil probably have some sort of helpers or whatever
// to make sure that you have the same response format for
// differents kind of responses. But let's return the
// below respose for now.
return response()->json([
'error' => 'Email does not exist.'
], 400);
}
// Verify the password and generate the token
if (Hash::check($this->request->input('password'), $user->password)) {
return response()->json([
'token' => $this->jwt($user)
], 200);
}
// Bad Request response
return response()->json([
'error' => 'Email or password is wrong.'
], 400);
}
}
, когда запрос выполняется в почтальоне с содержимым, установленным в application / json
dd($this->request->content); // output noting
dd($this->request->json()); // output []
dd($this->request->all()); // no hint of my json here, parameter bag is empty,
Я вижу, что мой json в сериализованной форме в содержании запроса, но я не могу получить к нему доступ.
Все отлично работает при использовании x-www-form-data.