aboutsummaryrefslogtreecommitdiff
path: root/app/Main.hs
blob: 94da2265125f861ae9a3d2e82d710da240c3fef2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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