summaryrefslogtreecommitdiff
path: root/Biz/Id.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Biz/Id.hs')
-rw-r--r--Biz/Id.hs7
1 files changed, 7 insertions, 0 deletions
diff --git a/Biz/Id.hs b/Biz/Id.hs
index 9bce013..4635f7f 100644
--- a/Biz/Id.hs
+++ b/Biz/Id.hs
@@ -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