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
317db4b6
Verified
Commit
317db4b6
authored
May 3, 2019
by
jan.hamal.dvorak
Browse files
Options
Downloads
Patches
Plain Diff
Use Route () instead of Route Void
Signed-off-by:
Jan Hamal Dvořák
<
mordae@anilinux.org
>
parent
b36e33cc
Branches
Branches containing commit
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/Route.hs
+21
-21
21 additions, 21 deletions
lib/Web/Hikaru/Route.hs
with
21 additions
and
21 deletions
lib/Web/Hikaru/Route.hs
+
21
−
21
View file @
317db4b6
...
...
@@ -271,10 +271,10 @@ where
-- |
-- Score route with respect to the request using the supplied function.
--
score
::
(
Request
->
Result
)
->
Route
Void
score
::
(
Request
->
Result
)
->
Route
()
score
fn
=
Route
\
env
@
Env
{
..
}
->
(
env
{
envScoring
=
fn
:
envScoring
},
Just
(
error
"void"
))
(
env
{
envScoring
=
fn
:
envScoring
},
Just
()
)
-- |
...
...
@@ -286,10 +286,10 @@ where
-- your action performs some kind of additional content negotiation.
-- All the scoring functions in this module do this automatically.
--
vary
::
[
HeaderName
]
->
Route
Void
vary
::
[
HeaderName
]
->
Route
()
vary
hs
=
Route
\
env
@
Env
{
..
}
->
(
env
{
envVary
=
hs
<>
envVary
},
Just
(
error
"void"
))
(
env
{
envVary
=
hs
<>
envVary
},
Just
()
)
-- Methods -----------------------------------------------------------------
...
...
@@ -300,7 +300,7 @@ where
--
-- Fails with 'MethodNotAllowed' if a different method was used.
--
method
::
Method
->
Route
Void
method
::
Method
->
Route
()
method
meth
=
score
\
req
->
if
meth
==
requestMethod
req
then
Success
1.0
...
...
@@ -310,42 +310,42 @@ where
-- |
-- Same as 'method' with the @GET@ argument.
--
get
::
Route
Void
get
::
Route
()
get
=
method
"GET"
-- |
-- Same as 'method' with the @POST@ argument.
--
post
::
Route
Void
post
::
Route
()
post
=
method
"POST"
-- |
-- Same as 'method' with the @HEAD@ argument.
--
head
::
Route
Void
head
::
Route
()
head
=
method
"HEAD"
-- |
-- Same as 'method' with the @PUT@ argument.
--
put
::
Route
Void
put
::
Route
()
put
=
method
"PUT"
-- |
-- Same as 'method' with the @PATCH@ argument.
--
patch
::
Route
Void
patch
::
Route
()
patch
=
method
"PATCH"
-- |
-- Same as 'method' with the @DELETE@ argument.
--
delete
::
Route
Void
delete
::
Route
()
delete
=
method
"DELETE"
...
...
@@ -354,7 +354,7 @@ where
-- media types and fail with 'UnsupportedMediaType' if not.
-- Adds @Vary: Content-Type@.
--
acceptContent
::
[
Media
]
->
Route
Void
acceptContent
::
[
Media
]
->
Route
()
acceptContent
media
=
vary
[
hContentType
]
<*
score
\
req
->
let
header
=
parseMedia
(
cs
$
getContentType
req
)
...
...
@@ -366,7 +366,7 @@ where
-- |
-- Shortcut to accept only form submissions.
--
acceptForm
::
Route
Void
acceptForm
::
Route
()
acceptForm
=
acceptContent
[
"application/x-www-form-urlencoded"
,
"multipart/form-data"
]
...
...
@@ -375,7 +375,7 @@ where
-- |
-- Shortcut to accept only JSON documents.
--
acceptJSON
::
Route
Void
acceptJSON
::
Route
()
acceptJSON
=
acceptContent
[
"application/json"
,
"text/json"
]
...
...
@@ -385,7 +385,7 @@ where
-- Check that we can send an acceptable response to the client and
-- fail with 'NotAcceptable' if not. Add @Vary: Accept@.
--
offerContent
::
[
Media
]
->
Route
Void
offerContent
::
[
Media
]
->
Route
()
offerContent
media
=
vary
[
hAccept
]
<*
score
\
req
->
let
header
=
parseMedia
(
cs
$
getAccept
req
)
...
...
@@ -397,21 +397,21 @@ where
-- |
-- Shortcut to offer HTML replies only.
--
offerHTML
::
Route
Void
offerHTML
::
Route
()
offerHTML
=
offerContent
[
"text/html"
]
-- |
-- Shortcut to offer plain text replies only.
--
offerText
::
Route
Void
offerText
::
Route
()
offerText
=
offerContent
[
"text/plain"
]
-- |
-- Shortcut to offer JSON replies only.
--
offerJSON
::
Route
Void
offerJSON
::
Route
()
offerJSON
=
offerContent
[
"application/json"
]
...
...
@@ -419,7 +419,7 @@ where
-- Check that we can send an acceptable charset to the client and
-- fail with 'NotAcceptable' if not. Add @Vary: Accept-Charset@.
--
offerCharset
::
[
Media
]
->
Route
Void
offerCharset
::
[
Media
]
->
Route
()
offerCharset
media
=
vary
[
hAcceptCharset
]
<*
score
\
req
->
let
header
=
parseMedia
(
cs
$
getAcceptCharset
req
)
...
...
@@ -432,7 +432,7 @@ where
-- Check that we can send an acceptable encoding to the client and
-- fail with 'NotAcceptable' if not. Add @Vary: Accept-Encoding@.
--
offerEncoding
::
[
Media
]
->
Route
Void
offerEncoding
::
[
Media
]
->
Route
()
offerEncoding
media
=
vary
[
hAcceptEncoding
]
<*
score
\
req
->
let
header
=
parseMedia
(
cs
$
getAcceptEncoding
req
)
...
...
@@ -445,7 +445,7 @@ where
-- Check that we can send an acceptable language to the client and
-- fail with 'NotAcceptable' if not. Add @Vary: Accept-Language@.
--
offerLanguage
::
[
Media
]
->
Route
Void
offerLanguage
::
[
Media
]
->
Route
()
offerLanguage
media
=
vary
[
hAcceptLanguage
]
<*
score
\
req
->
let
header
=
parseMedia
(
cs
$
getAcceptLanguage
req
)
...
...
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
sign in
to comment