diff options
Diffstat (limited to 'Biz/Id.hs')
-rw-r--r-- | Biz/Id.hs | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -14,6 +14,7 @@ import Alpha import Data.Aeson (FromJSON (..), ToJSON (..)) import Data.Binary (Binary) import Data.Data (Data) +import Servant (FromHttpApiData (..), ToHttpApiData (..)) newtype Id entity = Id Int deriving (Eq, Ord, Show, Generic, Typeable, Data) @@ -47,3 +48,9 @@ instance Semigroup (Id entity) where instance Monoid (Id entity) where mempty = mk (Proxy :: Proxy entity) 0 + +instance FromHttpApiData (Id entity) where + parseUrlPiece p = mk (Proxy :: Proxy entity) </ parseUrlPiece p + +instance ToHttpApiData (Id entity) where + toUrlPiece p = untag p |> tshow |