on master help sign in
roboservant/test/Product.hs
31 lines 653 B history raw
1{-# LANGUAGE DataKinds #-}
2{-# LANGUAGE DeriveGeneric #-}
3{-# LANGUAGE DerivingStrategies #-}
5{-# LANGUAGE OverloadedStrings #-}
6{-# LANGUAGE TypeOperators #-}
8module Product where
10import Data.Aeson
11import Data.Hashable
12import Data.Typeable (Typeable)
13import GHC.Generics (Generic)
14import Servant
16data Foo = Foo Int String
17 deriving (Generic, Eq, Show, Typeable)
19instance Hashable Foo
21instance ToJSON Foo
23instance FromJSON Foo
25type Api = "item" :> ReqBody '[JSON] Foo :> Post '[JSON] ()
27eliminate :: Foo -> Handler ()
28eliminate (Foo _a _b) = throwError $ err500 {errBody = "eliminate blew up, oh no!"}
30server :: Server Api
31server = eliminate