我想向这样的网络路由发送一些数据:
error: future cannot be sent between threads safely
--> src/main.rs:17:7
|
17 | }.boxed()
| ^^^^^ future created by async block is not `Send`
|
= help: within `impl futures::Future`, the trait `std::marker::Send` is not implemented for `std::sync::MutexGuard<'_, Client>`
note: future is not `Send` as this value is used across an await
--> src/main.rs:15:9
|
14 | let c = client.lock().unwrap();
| - has type `std::sync::MutexGuard<'_, Client>` which is not `Send`
15 | do_something(client.clone()).await;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ await occurs here, with `c` maybe used later
16 | Ok(())
17 | }.boxed()
| - `c` is later dropped here
然后在 <form action="{{ route('questions.answers', $show->id, $show->user->name) }}" method="POST">
上,我添加了以下内容:
web.php
但现在它说:
缺少 [Route: questions.answers] 的必需参数
那么这里出了什么问题?我如何将 Route::post('questions/{question}{asker}/answer' , [QuestionController::class, 'postAnswer'])->name('questions.answers');
和 $show->id
传递到 $show->user->name
路线?
我真的很感激你们的任何想法或建议......
提前致谢。
答案 0 :(得分:0)
如果要将 answer
作为参数传递,可以使用以下代码:
您的刀片文件
<form method="post" action="{{ route('questions.answers', ['question' => '', 'asker' => '', 'answer' => '']) }}" enctype="multipart/form-data">
@csrf
//---Your Data
</form>
web.php
Route::post('questions/{question}/{asker}/{answer}' , [QuestionController::class, 'postAnswer'])->name('questions.answers');
如果您想在表单中发送答案,请使用以下代码:
您的刀片文件
<form method="post" action="{{ route('questions.answers', ['question' => '', 'asker' => '']) }}" enctype="multipart/form-data">
@csrf
//---Your Answer Here
</form>
web.php
Route::post('questions/{question}/{asker}' , [QuestionController::class, 'postAnswer'])->name('questions.answers');