refactor(handlers): Receive search terms via query parameters
There are several reasons for this, but one important one is that people expect to be able to share search links.
This commit is contained in:
parent
e0b1bc2627
commit
ba33efd772
4 changed files with 6 additions and 6 deletions
|
@ -179,9 +179,9 @@ pub fn reply_thread(state: State<AppState>,
|
|||
/// This handler executes a full-text search on the forum database and
|
||||
/// displays the results to the user.
|
||||
pub fn search_forum(state: State<AppState>,
|
||||
query: Form<SearchPosts>) -> ConverseResponse {
|
||||
let query_string = query.0.query.clone();
|
||||
state.db.send(query.0)
|
||||
query: Query<SearchPosts>) -> ConverseResponse {
|
||||
let query_string = query.query.clone();
|
||||
state.db.send(query.into_inner())
|
||||
.flatten()
|
||||
.and_then(move |results| state.renderer.send(SearchResultPage {
|
||||
results,
|
||||
|
|
|
@ -153,7 +153,7 @@ fn main() {
|
|||
.resource("/thread/submit", |r| r.method(Method::POST).with3(submit_thread))
|
||||
.resource("/thread/reply", |r| r.method(Method::POST).with3(reply_thread))
|
||||
.resource("/thread/{id}", |r| r.method(Method::GET).with2(forum_thread))
|
||||
.resource("/search", |r| r.method(Method::POST).with2(search_forum))
|
||||
.resource("/search", |r| r.method(Method::GET).with2(search_forum))
|
||||
.resource("/oidc/login", |r| r.method(Method::GET).with(login))
|
||||
.resource("/oidc/callback", |r| r.method(Method::POST).with3(callback));
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
<a class="navbar-brand" href="/">
|
||||
<h2>Converse</h2>
|
||||
</a>
|
||||
<form class="form-inline" method="post" action="/search">
|
||||
<form class="form-inline" method="get" action="/search">
|
||||
<input class="form-control mr-sm-2" type="search" placeholder="Search" name="query" aria-label="Search">
|
||||
<button class="btn btn-outline-success my-2 my-sm-0 mr-1" type="submit">Search</button>
|
||||
<a class="btn btn-outline-secondary my-2" href="/thread/new">New thread</a>
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
<a class="navbar-brand" href="/">
|
||||
<h2>Converse</h2>
|
||||
</a>
|
||||
<form class="form-inline" method="post" action="/search">
|
||||
<form class="form-inline" method="get" action="/search">
|
||||
<input class="form-control mr-sm-2" type="search" placeholder="Search" name="query" aria-label="Search">
|
||||
<button class="btn btn-outline-success my-2 my-sm-0 mr-1" type="submit">Search</button>
|
||||
<a class="btn btn-outline-secondary my-2" href="/thread/new">New thread</a>
|
||||
|
|
Loading…
Reference in a new issue