summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthiasFischmann <>2020-07-31 18:29:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2020-07-31 18:29:00 (GMT)
commit14b40630d4a7e0b8f1d201b33961a11d5b5ea974 (patch)
tree9bfad773da3672c77dd7bc8917b6734595ae3850 /src
parent709a03143ca08256063d5d59dc524c6eefe41817 (diff)
version 0.180.18
Diffstat (limited to 'src')
-rw-r--r--src/Servant/API/Header.hs2
-rw-r--r--src/Servant/API/ResponseHeaders.hs2
-rw-r--r--src/Servant/API/Status.hs155
-rw-r--r--src/Servant/Links.hs6
4 files changed, 160 insertions, 5 deletions
diff --git a/src/Servant/API/Header.hs b/src/Servant/API/Header.hs
index 14562df..e5ea1e0 100644
--- a/src/Servant/API/Header.hs
+++ b/src/Servant/API/Header.hs
@@ -23,7 +23,7 @@ import Servant.API.Modifiers
-- >>> type MyApi = "view-my-referer" :> Header "from" Referer :> Get '[JSON] Referer
type Header = Header' '[Optional, Strict]
-data Header' (mods :: [*]) (sym :: Symbol) a
+data Header' (mods :: [*]) (sym :: Symbol) (a :: *)
deriving Typeable
-- $setup
diff --git a/src/Servant/API/ResponseHeaders.hs b/src/Servant/API/ResponseHeaders.hs
index 6ca42b6..b5f98af 100644
--- a/src/Servant/API/ResponseHeaders.hs
+++ b/src/Servant/API/ResponseHeaders.hs
@@ -95,7 +95,7 @@ type family HeaderValMap (f :: * -> *) (xs :: [*]) where
class BuildHeadersTo hs where
buildHeadersTo :: [HTTP.Header] -> HList hs
- -- ^ Note: if there are multiple occurences of a header in the argument,
+ -- ^ Note: if there are multiple occurrences of a header in the argument,
-- the values are interspersed with commas before deserialization (see
-- <http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2 RFC2616 Sec 4.2>)
diff --git a/src/Servant/API/Status.hs b/src/Servant/API/Status.hs
new file mode 100644
index 0000000..ee334fc
--- /dev/null
+++ b/src/Servant/API/Status.hs
@@ -0,0 +1,155 @@
+{-# LANGUAGE DataKinds #-}
+-- Flexible instances is necessary on GHC 8.4 and earlier
+{-# LANGUAGE FlexibleInstances #-}
+module Servant.API.Status where
+
+import Network.HTTP.Types.Status
+import GHC.TypeLits
+
+-- | Witness that a type-level natural number corresponds to a HTTP status code
+class KnownNat n => KnownStatus n where
+ statusVal :: proxy n -> Status
+
+instance KnownStatus 100 where
+ statusVal _ = status100
+
+instance KnownStatus 101 where
+ statusVal _ = status101
+
+instance KnownStatus 200 where
+ statusVal _ = status200
+
+instance KnownStatus 201 where
+ statusVal _ = status201
+
+instance KnownStatus 202 where
+ statusVal _ = status202
+
+instance KnownStatus 203 where
+ statusVal _ = status203
+
+instance KnownStatus 204 where
+ statusVal _ = status204
+
+instance KnownStatus 205 where
+ statusVal _ = status205
+
+instance KnownStatus 206 where
+ statusVal _ = status206
+
+instance KnownStatus 300 where
+ statusVal _ = status300
+
+instance KnownStatus 301 where
+ statusVal _ = status301
+
+instance KnownStatus 302 where
+ statusVal _ = status302
+
+instance KnownStatus 303 where
+ statusVal _ = status303
+
+instance KnownStatus 304 where
+ statusVal _ = status304
+
+instance KnownStatus 305 where
+ statusVal _ = status305
+
+instance KnownStatus 307 where
+ statusVal _ = status307
+
+instance KnownStatus 308 where
+ statusVal _ = status308
+
+instance KnownStatus 400 where
+ statusVal _ = status400
+
+instance KnownStatus 401 where
+ statusVal _ = status401
+
+instance KnownStatus 402 where
+ statusVal _ = status402
+
+instance KnownStatus 403 where
+ statusVal _ = status403
+
+instance KnownStatus 404 where
+ statusVal _ = status404
+
+instance KnownStatus 405 where
+ statusVal _ = status405
+
+instance KnownStatus 406 where
+ statusVal _ = status406
+
+instance KnownStatus 407 where
+ statusVal _ = status407
+
+instance KnownStatus 408 where
+ statusVal _ = status408
+
+instance KnownStatus 409 where
+ statusVal _ = status409
+
+instance KnownStatus 410 where
+ statusVal _ = status410
+
+instance KnownStatus 411 where
+ statusVal _ = status411
+
+instance KnownStatus 412 where
+ statusVal _ = status412
+
+instance KnownStatus 413 where
+ statusVal _ = status413
+
+instance KnownStatus 414 where
+ statusVal _ = status414
+
+instance KnownStatus 415 where
+ statusVal _ = status415
+
+instance KnownStatus 416 where
+ statusVal _ = status416
+
+instance KnownStatus 417 where
+ statusVal _ = status417
+
+instance KnownStatus 418 where
+ statusVal _ = status418
+
+instance KnownStatus 422 where
+ statusVal _ = status422
+
+instance KnownStatus 426 where
+ statusVal _ = status426
+
+instance KnownStatus 428 where
+ statusVal _ = status428
+
+instance KnownStatus 429 where
+ statusVal _ = status429
+
+instance KnownStatus 431 where
+ statusVal _ = status431
+
+instance KnownStatus 500 where
+ statusVal _ = status500
+
+instance KnownStatus 501 where
+ statusVal _ = status501
+
+instance KnownStatus 502 where
+ statusVal _ = status502
+
+instance KnownStatus 503 where
+ statusVal _ = status503
+
+instance KnownStatus 504 where
+ statusVal _ = status504
+
+instance KnownStatus 505 where
+ statusVal _ = status505
+
+instance KnownStatus 511 where
+ statusVal _ = status511
diff --git a/src/Servant/Links.hs b/src/Servant/Links.hs
index 0d07c20..b42738e 100644
--- a/src/Servant/Links.hs
+++ b/src/Servant/Links.hs
@@ -54,7 +54,7 @@
-- >>> toUrlPiece $ safeLink api without
-- "bye"
--
--- If you would like create a helper for generating links only within that API,
+-- If you would like to create a helper for generating links only within that API,
-- you can partially apply safeLink if you specify a correct type signature
-- like so:
--
@@ -65,7 +65,7 @@
-- >>> apiLink = safeLink api
-- >>> :}
--
--- `safeLink'` allows to make specialise the output:
+-- `safeLink'` allows you to specialise the output:
--
-- >>> safeLink' toUrlPiece api without
-- "bye"
@@ -563,7 +563,7 @@ instance HasLink sub => HasLink (AuthProtect tag :> sub) where
type MkLink (AuthProtect tag :> sub) a = MkLink sub a
toLink = simpleToLink (Proxy :: Proxy sub)
--- | Helper for implemneting 'toLink' for combinators not affecting link
+-- | Helper for implementing 'toLink' for combinators not affecting link
-- structure.
simpleToLink
:: forall sub a combinator.