summaryrefslogtreecommitdiff
path: root/src/server/PGFService.hs
diff options
context:
space:
mode:
authorhallgren <hallgren@chalmers.se>2013-01-09 13:28:45 +0000
committerhallgren <hallgren@chalmers.se>2013-01-09 13:28:45 +0000
commit1497fd863ae7b1d4b2c1f7144a1d2753875bae75 (patch)
treeb0ef46ada23c974e8b59492b73295ebcb6d4e9ab /src/server/PGFService.hs
parent580e443a5eb731b50a84a7bc9aa9c3007d3a50f2 (diff)
PGF service: new command: download
This makes it possible to download PGF files from servers where the PGF service is installed. I am also considering making commmand=download the default instead of command=grammar.
Diffstat (limited to 'src/server/PGFService.hs')
-rw-r--r--src/server/PGFService.hs7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/server/PGFService.hs b/src/server/PGFService.hs
index ed19541f1..ee83394da 100644
--- a/src/server/PGFService.hs
+++ b/src/server/PGFService.hs
@@ -51,11 +51,12 @@ cgiMain' cache path =
do pgf <- liftIO $ readCache cache path
command <- liftM (maybe "grammar" (urlDecodeUnicode . UTF8.decodeString))
(getInput "command")
- pgfMain pgf command
+ pgfMain path pgf command
-pgfMain :: PGF -> String -> CGI CGIResult
-pgfMain pgf command =
+pgfMain :: FilePath -> PGF -> String -> CGI CGIResult
+pgfMain path pgf command =
case command of
+ "download" -> outputBinary =<< liftIO (BS.readFile path)
"parse" -> outputJSONP =<< doParse pgf `fmap` getText `ap` getCat `ap` getFrom `ap` getLimit
"complete" -> outputJSONP =<< doComplete pgf `fmap` getText `ap` getCat `ap` getFrom `ap` getLimit
"linearize" -> outputJSONP =<< doLinearize pgf `fmap` getTree `ap` getTo