From 55d1e6c9a9f41394a37b48c42f65cc02274b9ab7 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Tue, 22 Nov 2022 23:13:06 +1100 Subject: initial commit --- app/Main.hs | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 app/Main.hs (limited to 'app/Main.hs') diff --git a/app/Main.hs b/app/Main.hs new file mode 100644 index 0000000..94da226 --- /dev/null +++ b/app/Main.hs @@ -0,0 +1,40 @@ +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE TypeOperators #-} +module Main where + +import Data.Proxy ( Proxy(..) ) +import Data.Text ( Text ) +import qualified Data.Text as T +import Network.Wai.Handler.Warp ( run ) +import Servant ( (:>) + , Application + , CaptureAll + , Get + , Handler + , JSON + , Server + , serve + ) + +type API = GetPageCompliance + +type GetPageCompliance = CaptureAll "url" Text :> Get '[JSON] Text + +server :: Server API +server = getPageCompliance + +getPageCompliance :: [Text] -> Handler Text +getPageCompliance url = + return + $ "You have requested librejs-compliance info for " + <> T.intercalate "/" url + +app :: Application +app = serve api server + +api :: Proxy API +api = Proxy + +main :: IO () +main = run 5678 app -- cgit v1.2.3