src/server: refactoring to isolate dependencies on the cgi/fastcgi packages

* Introducing the module CGI, re-exporting a subset of the cgi package. It
  might complete replace the cgi package in the future.
* Introducing the module CGIUtils, containing functions from FastCGIUtils that
  have nothing to do with fastcgi.

Some low level hackery with unsafePerformIO and global variables was left
in FastCGIUtils, but it is actually not used, neither for gf -server nor
exec/pgf-fcgi.hs.
This commit is contained in:
hallgren
2014-09-02 12:27:47 +00:00
parent bfd414554d
commit e0e6079c91
11 changed files with 149 additions and 128 deletions

View File

@@ -7,7 +7,11 @@ import PGF (PGF)
import qualified PGF
import PGF.Lexing
import Cache
import FastCGIUtils
import CGIUtils(outputJSONP,outputPlain,outputHTML,logError,outputBinary,
outputBinary',handleCGIErrors,throwCGIError,stderrToFile)
import CGI(CGI,readInput,getInput,getVarWithDefault,
CGIResult,requestAcceptLanguage,handleErrors,setHeader,
Accept(..),Language(..),negotiate,liftIO)
import URLEncoding
#if C_RUNTIME
@@ -18,7 +22,6 @@ import qualified PGF2 as C
import Data.Time.Clock(UTCTime)
import Data.Time.Format(formatTime)
import System.Locale(defaultTimeLocale,rfc822DateFormat)
import Network.CGI
import Text.JSON
import Text.PrettyPrint as PP(render, text, (<+>))
import qualified Codec.Binary.UTF8.String as UTF8 (decodeString)
@@ -687,9 +690,7 @@ outputGraphviz code =
"gv" -> outputPlain code
_ -> outputFPS' fmt =<< liftIO (pipeIt2graphviz fmt code)
where
outputFPS' fmt bs =
do setHeader "Content-Type" (mimeType fmt)
outputFPS bs
outputFPS' = outputBinary' . mimeType
mimeType fmt =
case fmt of