mirror of
https://github.com/ilyakooo0/roboservant.git
synced 2024-10-05 12:37:17 +03:00
32 lines
653 B
Haskell
32 lines
653 B
Haskell
{-# LANGUAGE DataKinds #-}
|
|
{-# LANGUAGE DeriveGeneric #-}
|
|
{-# LANGUAGE DerivingStrategies #-}
|
|
|
|
{-# LANGUAGE OverloadedStrings #-}
|
|
{-# LANGUAGE TypeOperators #-}
|
|
|
|
module Product where
|
|
|
|
import Data.Aeson
|
|
import Data.Hashable
|
|
import Data.Typeable (Typeable)
|
|
import GHC.Generics (Generic)
|
|
import Servant
|
|
|
|
data Foo = Foo Int String
|
|
deriving (Generic, Eq, Show, Typeable)
|
|
|
|
instance Hashable Foo
|
|
|
|
instance ToJSON Foo
|
|
|
|
instance FromJSON Foo
|
|
|
|
type Api = "item" :> ReqBody '[JSON] Foo :> Post '[JSON] ()
|
|
|
|
eliminate :: Foo -> Handler ()
|
|
eliminate (Foo _a _b) = throwError $ err500 {errBody = "eliminate blew up, oh no!"}
|
|
|
|
server :: Server Api
|
|
server = eliminate
|