Skip to content

Commit

Permalink
Use full header type in response header instances
Browse files Browse the repository at this point in the history
This is required to be able provide `Description` into headers, for
example like this:
```
type PaginationTotalCountHeader =
  Header'
    '[ Description "Indicates to the client total count of items in collection"
     , Optional
     , Strict
     ]
    "Total-Count"
    Int
```
  • Loading branch information
worm2fed committed Jul 19, 2023
1 parent 02242e9 commit 984fa5b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions servant/src/Servant/API/ResponseHeaders.hs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ module Servant.API.ResponseHeaders
import Control.DeepSeq
(NFData (..))
import Data.ByteString.Char8 as BS
(ByteString, init, pack, unlines)
(ByteString, pack)
import qualified Data.CaseInsensitive as CI
import qualified Data.List as L
import Data.Proxy
Expand All @@ -52,7 +52,7 @@ import Web.HttpApiData
import Prelude ()
import Prelude.Compat
import Servant.API.Header
(Header)
(Header, Header')
import Servant.API.UVerb.Union
import qualified Data.SOP.BasicFunctors as SOP
import qualified Data.SOP.NS as SOP
Expand Down Expand Up @@ -130,7 +130,7 @@ instance GetHeadersFromHList '[] where
getHeadersFromHList _ = []

instance (KnownSymbol h, ToHttpApiData x, GetHeadersFromHList xs)
=> GetHeadersFromHList (Header h x ': xs)
=> GetHeadersFromHList (Header' mods h x ': xs)
where
getHeadersFromHList hdrs = case hdrs of
Header val `HCons` rest -> (headerName , toHeader val) : getHeadersFromHList rest
Expand All @@ -151,7 +151,7 @@ instance GetHeaders' '[] where
getHeaders' _ = []

instance (KnownSymbol h, GetHeadersFromHList rest, ToHttpApiData v)
=> GetHeaders' (Header h v ': rest)
=> GetHeaders' (Header' mods h v ': rest)
where
getHeaders' hs = getHeadersFromHList $ getHeadersHList hs

Expand Down

0 comments on commit 984fa5b

Please sign in to comment.