quiet-cartoon-75498
05/09/2023, 7:42 PMhtml
<input class="form-control"
name="search"
placeholder="Begin Typing To Search Users..."
hx-get="/search/:name"
hx-include="[name='search']"
hx-trigger="keyup changed delay:500ms"
hx-target="#search-results"
>
<div id="search-results"></div>
and this is my handler and main function setting up the axum server
rust
async fn get_profile(Path(profile_name): Path<String>) -> Html<String> {
let orders_example = vec![
Item {
id: 1,
name: "Article banana".into(),
},
Item {
id: 2,
name: "Article apple".into(),
},
];
let profile_example = Profile {
full_name: profile_name,
items: orders_example,
};
let r = render!(PROFILE_TEMPLATE, profile => profile_example);
Html(r)
}
//....
#[tokio::main]
async fn main() {
let app = Router::new()
.route(
"/",
get(home),
)
.route(
"/search/:name",
get(get_profile).post(get_profile),
);
axum::Server::bind(&"0.0.0.0:3000".parse().unwrap())
.serve(app.into_make_service())
.await
.unwrap();
}
In its current state, it will show the name as ":Name". I know if I manually edit the path of the request to e.g. /search/joe the name will show up as Joe, but I struggle to see how I can feed the typed value from the input box to the URI.