diff options
Diffstat (limited to 'lambda-calcul/haskell/src/Minilang/API.hs')
| -rw-r--r-- | lambda-calcul/haskell/src/Minilang/API.hs | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/lambda-calcul/haskell/src/Minilang/API.hs b/lambda-calcul/haskell/src/Minilang/API.hs index c9cde53..04eda7b 100644 --- a/lambda-calcul/haskell/src/Minilang/API.hs +++ b/lambda-calcul/haskell/src/Minilang/API.hs @@ -16,9 +16,16 @@ import qualified Data.ByteString.Lazy as LBS import Data.Text (Text) import Data.Time (UTCTime) import GHC.Generics (Generic) -import Servant (FromHttpApiData, Get, JSON, QueryParam, Raw, ReqBody, StdMethod (POST), ToHttpApiData, Verb, parseUrlPiece, toUrlPiece, (:<|>), (:>)) +import Servant (FromHttpApiData, Get, JSON, QueryParam, Raw, ReqBody, StdMethod (POST), ToHttpApiData, Verb, parseUrlPiece, toUrlPiece, (:<|>), (:>), Post) import System.Random (StdGen, uniformList) +type LambdaAPI = + "api" :> "register" :> ReqBody '[JSON] User :> Verb 'POST 201 '[JSON] Token + :<|> "api" :> "leaderboard" :> Get '[JSON] [Score] + :<|> "api" :> "challenge" :> QueryParam "token" Token :> Get '[JSON] Challenge + :<|> "api" :> "challenge" :> QueryParam "token" Token :> ReqBody '[JSON] Text :> Post '[JSON] () + :<|> Raw + data Score = Score { user :: User, grade :: Int, @@ -46,9 +53,3 @@ data Challenge = Challenge expr :: Text } deriving (Eq, Show, Generic, ToJSON, FromJSON) - -type LambdaAPI = - "api" :> "register" :> ReqBody '[JSON] User :> Verb 'POST 201 '[JSON] Token - :<|> "api" :> "leaderboard" :> Get '[JSON] [Score] - :<|> "api" :> "challenge" :> QueryParam "token" Token :> Get '[JSON] Challenge - :<|> Raw |
