aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/Server.hs16
1 files changed, 12 insertions, 4 deletions
diff --git a/app/Server.hs b/app/Server.hs
index 1c9980d..e4efd36 100644
--- a/app/Server.hs
+++ b/app/Server.hs
@@ -48,7 +48,7 @@ import Data.IntervalMap.Interval (Interval(..), subsumes)
import qualified Data.IntervalMap.Strict as IVM
import qualified Data.List as L
import qualified Data.Map.Strict as M
-import Data.Maybe (fromMaybe, listToMaybe, mapMaybe)
+import Data.Maybe (fromMaybe, mapMaybe)
import qualified Data.Vector as V
import qualified GHC.Compact as C
import Data.Pagination
@@ -67,7 +67,7 @@ import qualified Data.Text as T
import qualified Data.Text.Encoding as TE
import Data.Text.Lazy (toStrict)
import Data.Text.Read(decimal)
-import Data.Version (Version(..))
+import Data.Version (Version(..), showVersion)
import GHC.Exts (Down(..), groupWith)
import GHC.Generics (Generic)
import qualified HaskellCodeExplorer.Types as HCE
@@ -114,6 +114,7 @@ import Options.Applicative
, strOption
, switch
)
+import qualified Paths_hcel (version)
import Servant
( (:<|>)(..)
, (:>)
@@ -909,7 +910,8 @@ handleSync onError =
-- Servant API
--------------------------------------------------------------------------------
-type API = GetAllPackages
+type API = Greet
+ :<|> GetAllPackages
:<|> GetDefinitionSite
:<|> GetExpressions
:<|> GetReferences
@@ -920,6 +922,8 @@ type API = GetAllPackages
:<|> GetGlobalIdentifierE
:<|> GetHoogleDocs
+type Greet = "api" :> "greet" :> Get '[JSON] T.Text
+
type GetAllPackages = "api" :> "packages" :> Get '[JSON] AllPackages
type GetDefinitionSite = "api" :> "definitionSite"
@@ -1067,6 +1071,9 @@ data SourceFile = SourceFile
instance A.ToJSON ReferenceWithSource
instance A.ToJSON SourceFile
+greet :: ReaderT Environment IO T.Text
+greet = return $ T.pack $ showVersion Paths_hcel.version
+
getAllPackages :: ReaderT Environment IO AllPackages
getAllPackages = asks envPackageVersions
@@ -1853,7 +1860,8 @@ server env =
hoistServer
(Proxy :: Proxy API)
toServantHandler
- (getAllPackages :<|>
+ (greet :<|>
+ getAllPackages :<|>
getDefinitionSite :<|>
getExpressions :<|>
getReferences :<|>