Skip to content
Snippets Groups Projects
Commit d377be4b authored by codecraft's avatar codecraft :crocodile:
Browse files

Approach from request forms/data

add a get request with form
parent 8c05e9c3
No related branches found
No related tags found
1 merge request!1Initial feature merge
......@@ -2,10 +2,7 @@
use std::{collections::HashMap, error::Error, fmt::Display};
use mime::Mime;
use super::{
file_handlers::find_mimetype,
methods::Method,
routes::{Data, Uri},
};
......@@ -66,6 +63,7 @@ impl Request<'_> {
_ => false,
}
}
// pub fn get_post_form_key<T: FromRequest>(&self, data: Data) -> T {}
pub fn get_get_form_keys(
&self,
keys: Vec<&str>,
......
......@@ -15,5 +15,12 @@
<input type="text" id="asdf" name="message" />
<button type="submit">Send</button>
</form>
<form action="/static/hi" method="get">
<label for="jump">Enter asdf</label>
<input type="text" id="jump" name="asdf" />
<label for="jkl">Enter jkl;</label>
<input type="text" id="jkl" name="jkl" />
<button type="submit">Send</button>
</form>
</body>
</html>
......@@ -21,7 +21,7 @@ fn hashmap_to_string(map: &HashMap<&str, &str>) -> String {
}
fn handle_static_hi(request: Request<'_>, data: Data) -> Outcome<Response, Status, Data> {
let keys = if let Ok(keys) = request.get_get_form_keys(vec!["asdf", "jkl;"]) {
let keys = if let Ok(keys) = request.get_get_form_keys(vec!["asdf", "jkl"]) {
keys
} else {
return Outcome::Forward(data);
......@@ -111,7 +111,7 @@ async fn main() {
rank: 0,
};
http::build("127.0.0.1:8000")
http::build("192.168.178.32:8000")
.await
.mount("/", vec![fileserver, post_test, static_hi])
.mount("/post/", vec![post_test])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment