Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
hikaru
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TO
hikaru
Commits
aad94594
Verified
Commit
aad94594
authored
6 years ago
by
jan.hamal.dvorak
Browse files
Options
Downloads
Patches
Plain Diff
Clean up Action types a bit
Signed-off-by:
Jan Hamal Dvořák
<
mordae@anilinux.org
>
parent
eee85ce3
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/Web/Hikaru/Action.hs
+20
-8
20 additions, 8 deletions
lib/Web/Hikaru/Action.hs
with
20 additions
and
8 deletions
lib/Web/Hikaru/Action.hs
+
20
−
8
View file @
aad94594
...
@@ -221,6 +221,12 @@ where
...
@@ -221,6 +221,12 @@ where
type
ResponseMaker
=
Status
->
ResponseHeaders
->
Response
type
ResponseMaker
=
Status
->
ResponseHeaders
->
Response
-- |
-- Fields and files sent using a web form.
--
type
FormData
=
([(
Text
,
Text
)],
[(
Text
,
FileInfo
FilePath
)])
-- |
-- |
-- Types of the request body.
-- Types of the request body.
--
--
...
@@ -229,7 +235,7 @@ where
...
@@ -229,7 +235,7 @@ where
-- ^ Body has not yet been touched.
-- ^ Body has not yet been touched.
|
BodyTainted
|
BodyTainted
-- ^ Body has been partially consumed.
-- ^ Body has been partially consumed.
|
BodyForm
([(
Text
,
Text
)],
[(
Text
,
FileInfo
FilePath
)])
|
BodyForm
FormData
-- ^ Body has been successfully parsed as a form.
-- ^ Body has been successfully parsed as a form.
|
BodyJSON
Value
|
BodyJSON
Value
-- ^ Body has been successfully parsed as a JSON.
-- ^ Body has been successfully parsed as a JSON.
...
@@ -608,7 +614,7 @@ where
...
@@ -608,7 +614,7 @@ where
-- Use 'setBodyLimit' to adjust the limit to your liking.
-- Use 'setBodyLimit' to adjust the limit to your liking.
--
--
getFields
::
(
MonadAction
m
)
=>
m
[(
Text
,
Text
)]
getFields
::
(
MonadAction
m
)
=>
m
[(
Text
,
Text
)]
getFields
=
map
cs2
<$>
fst
<$>
getForm
getFields
=
map
cs2
<$>
fst
<$>
getForm
Data
-- |
-- |
...
@@ -644,7 +650,7 @@ where
...
@@ -644,7 +650,7 @@ where
-- files uploaded through the form.
-- files uploaded through the form.
--
--
getFiles
::
(
MonadAction
m
)
=>
m
[(
Text
,
FileInfo
FilePath
)]
getFiles
::
(
MonadAction
m
)
=>
m
[(
Text
,
FileInfo
FilePath
)]
getFiles
=
snd
<$>
getForm
getFiles
=
snd
<$>
getForm
Data
-- |
-- |
...
@@ -667,9 +673,16 @@ where
...
@@ -667,9 +673,16 @@ where
-- Backend for both 'getFields' and 'getFiles' that parses,
-- Backend for both 'getFields' and 'getFiles' that parses,
-- caches and returns form data.
-- caches and returns form data.
--
--
getForm
::
(
MonadAction
m
)
-- * Throws 'UnsupportedMediaType' if the Content-Type does not
=>
m
([(
Text
,
Text
)],
[(
Text
,
FileInfo
FilePath
)])
-- indicate a form payload.
getForm
=
do
--
-- * Throws 'BadRequest' if the payload fails to parse.
--
-- * Throws 'PayloadTooLarge' if the payload size limit is exceeded.
-- Use 'setBodyLimit' to adjust the limit to your liking.
--
getFormData
::
(
MonadAction
m
)
=>
m
FormData
getFormData
=
do
cache
<-
getActionField
aeBody
cache
<-
getActionField
aeBody
case
cache
of
case
cache
of
...
@@ -708,8 +721,7 @@ where
...
@@ -708,8 +721,7 @@ where
-- |
-- |
-- Convert form names and fields from 'ByteString' to 'Text'.
-- Convert form names and fields from 'ByteString' to 'Text'.
--
--
csForm
::
([
Param
],
[
File
FilePath
])
csForm
::
([
Param
],
[
File
FilePath
])
->
FormData
->
([(
Text
,
Text
)],
[(
Text
,
FileInfo
FilePath
)])
csForm
(
ps
,
fs
)
=
(
map
cs2
ps
,
map
cs1
fs
)
csForm
(
ps
,
fs
)
=
(
map
cs2
ps
,
map
cs1
fs
)
...
...
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