Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
WebServer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
codecraft
WebServer
Commits
d377be4b
Commit
d377be4b
authored
1 year ago
by
codecraft
Browse files
Options
Downloads
Patches
Plain Diff
Approach from request forms/data
add a get request with form
parent
8c05e9c3
No related branches found
No related tags found
1 merge request
!1
Initial feature merge
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
core/http/src/handling/request.rs
+1
-3
1 addition, 3 deletions
core/http/src/handling/request.rs
site/404.html
+7
-0
7 additions, 0 deletions
site/404.html
site/src/main.rs
+2
-2
2 additions, 2 deletions
site/src/main.rs
with
10 additions
and
5 deletions
core/http/src/handling/request.rs
+
1
−
3
View file @
d377be4b
...
...
@@ -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
>
,
...
...
This diff is collapsed.
Click to expand it.
site/404.html
+
7
−
0
View file @
d377be4b
...
...
@@ -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>
This diff is collapsed.
Click to expand it.
site/src/main.rs
+
2
−
2
View file @
d377be4b
...
...
@@ -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
(
"1
27.0.0.1
:8000"
)
http
::
build
(
"1
92.168.178.32
:8000"
)
.await
.mount
(
"/"
,
vec!
[
fileserver
,
post_test
,
static_hi
])
.mount
(
"/post/"
,
vec!
[
post_test
])
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment