Skip to content

Commit a8f584f

Browse files
authored
add HasLink instance for UVerb (#1370)
1 parent 08579ca commit a8f584f

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

servant/src/Servant/Links.hs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ import Servant.API.Stream
178178
import Servant.API.Sub
179179
(type (:>))
180180
import Servant.API.TypeLevel
181+
import Servant.API.UVerb
181182
import Servant.API.Vault
182183
(Vault)
183184
import Servant.API.Verbs
@@ -576,6 +577,11 @@ instance HasLink (Stream m status fr ct a) where
576577
type MkLink (Stream m status fr ct a) r = r
577578
toLink toA _ = toA
578579

580+
-- UVerb instances
581+
instance HasLink (UVerb m ct a) where
582+
type MkLink (UVerb m ct a) r = r
583+
toLink toA _ = toA
584+
579585
-- AuthProtext instances
580586
instance HasLink sub => HasLink (AuthProtect tag :> sub) where
581587
type MkLink (AuthProtect tag :> sub) a = MkLink sub a

servant/test/Servant/LinksSpec.hs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ type TestApi =
2929
-- Fragment
3030
:<|> "say" :> Fragment String :> Get '[JSON] NoContent
3131

32+
-- UVerb
33+
:<|> "uverb-example" :> UVerb 'GET '[JSON] '[WithStatus 200 NoContent]
34+
3235
-- All of the verbs
3336
:<|> "get" :> Get '[JSON] NoContent
3437
:<|> "put" :> Put '[JSON] NoContent
@@ -73,6 +76,10 @@ spec = describe "Servant.Links" $ do
7376
["roads", "lead", "to", "rome"]
7477
`shouldBeLink` "all/roads/lead/to/rome"
7578

79+
it "generated correct links for UVerbs" $ do
80+
apiLink (Proxy :: Proxy ("uverb-example" :> UVerb 'GET '[JSON] '[WithStatus 200 NoContent]))
81+
`shouldBeLink` "uverb-example"
82+
7683
it "generates correct links for query flags" $ do
7784
let l1 = Proxy :: Proxy ("balls" :> QueryFlag "bouncy"
7885
:> QueryFlag "fast" :> Delete '[JSON] NoContent)

0 commit comments

Comments
 (0)