shredded FastCGI and CGI support, as they are incompatible with WebSocket 😢
This commit is contained in:
parent
49f3b092be
commit
cf946f960c
9 changed files with 20 additions and 113 deletions
|
@ -1,5 +1,6 @@
|
||||||
|
{-# LANGUAGE CPP #-}
|
||||||
module Backend.Backend where
|
module Backend.Backend where
|
||||||
|
|
||||||
import Control.Concurrent.MVar
|
import Control.Concurrent.MVar
|
||||||
import qualified Network.Wai as Wai
|
import qualified Network.Wai as Wai
|
||||||
|
|
||||||
|
@ -9,12 +10,6 @@ import qualified Backend.Http as HTTP
|
||||||
#ifdef HTTPS_SUPPORT
|
#ifdef HTTPS_SUPPORT
|
||||||
import qualified Backend.Https as HTTPS
|
import qualified Backend.Https as HTTPS
|
||||||
#endif
|
#endif
|
||||||
#ifdef FASTCGI_SUPPORT
|
|
||||||
import qualified Backend.FastCGI as FASTCGI
|
|
||||||
#endif
|
|
||||||
#ifdef CGI_SUPPORT
|
|
||||||
import qualified Backend.CGI as CGI
|
|
||||||
#endif
|
|
||||||
-- maybe we want a String instead of T.Text depends on
|
-- maybe we want a String instead of T.Text depends on
|
||||||
-- the argument parser
|
-- the argument parser
|
||||||
|
|
||||||
|
@ -40,11 +35,5 @@ backends =
|
||||||
#endif
|
#endif
|
||||||
#ifdef HTTPS_SUPPORT
|
#ifdef HTTPS_SUPPORT
|
||||||
BackendWithConfig HTTPS.forkHttpsBackend "https" "Host as as simple https server, using Warp" :
|
BackendWithConfig HTTPS.forkHttpsBackend "https" "Host as as simple https server, using Warp" :
|
||||||
#endif
|
|
||||||
#ifdef FASTCGI_SUPPORT
|
|
||||||
BackendWithoutConfig FASTCGI.forkFastCGIBackend "fastcgi" "Deploy with fastcgi" :
|
|
||||||
#endif
|
|
||||||
#ifdef CGI_SUPPORT
|
|
||||||
BackendWithoutConfig CGI.forkCGIBackend "cgi" "Deploy with cgi" :
|
|
||||||
#endif
|
#endif
|
||||||
[]
|
[]
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
module Backend.CGI(forkCGIBackend) where
|
|
||||||
|
|
||||||
import Config
|
|
||||||
import qualified Network.Wai as Wai
|
|
||||||
import qualified Network.Wai.Handler.CGI as CGI
|
|
||||||
import Control.Concurrent.MVar
|
|
||||||
|
|
||||||
forkCGIBackend :: Wai.Application -> IO [MVar ()]
|
|
||||||
forkCGIBackend = fmap (: []) . forkBackend . CGI.run
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
module Backend.FastCGI where
|
|
||||||
|
|
||||||
import Config
|
|
||||||
import qualified Network.Wai as Wai
|
|
||||||
import qualified Network.Wai.Handler.FastCGI as Fcgi
|
|
||||||
import Control.Concurrent.MVar
|
|
||||||
|
|
||||||
forkFastCGIBackend :: Wai.Application -> IO [MVar ()]
|
|
||||||
forkFastCGIBackend = fmap (: []) . forkBackend . Fcgi.run
|
|
|
@ -1,3 +1,11 @@
|
||||||
|
{-# LANGUAGE CPP #-}
|
||||||
|
#ifndef HTTP_SUPPORT
|
||||||
|
module Backend.Http
|
||||||
|
where
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HTTP_SUPPORT
|
||||||
{-# LANGUAGE OverloadedStrings #-}
|
{-# LANGUAGE OverloadedStrings #-}
|
||||||
|
|
||||||
-- we export a bit more than we have to, because the https module can reuse these things.
|
-- we export a bit more than we have to, because the https module can reuse these things.
|
||||||
|
@ -78,3 +86,4 @@ httpToWarpConfig config' = HTTP.setPort confPort $ HTTP.setHost (fromString conf
|
||||||
|
|
||||||
backend :: Wai.Application -> HttpConfiguration -> IO ()
|
backend :: Wai.Application -> HttpConfiguration -> IO ()
|
||||||
backend app config = HTTP.runSettings (httpToWarpConfig config) app
|
backend app config = HTTP.runSettings (httpToWarpConfig config) app
|
||||||
|
#endif
|
||||||
|
|
|
@ -1,3 +1,9 @@
|
||||||
|
{-# LANGUAGE CPP #-}
|
||||||
|
#ifndef HTTPS_SUPPORT
|
||||||
|
module Backend.Https
|
||||||
|
where
|
||||||
|
|
||||||
|
#else
|
||||||
{-# LANGUAGE OverloadedStrings #-}
|
{-# LANGUAGE OverloadedStrings #-}
|
||||||
|
|
||||||
module Backend.Https (forkHttpsBackend, httpsDefaultSettings) where
|
module Backend.Https (forkHttpsBackend, httpsDefaultSettings) where
|
||||||
|
@ -74,3 +80,4 @@ httpsToWarpConfig = httpToWarpConfig . fst
|
||||||
|
|
||||||
backend :: Wai.Application -> HttpsConfiguration -> IO ()
|
backend :: Wai.Application -> HttpsConfiguration -> IO ()
|
||||||
backend app conf = HTTPS.runTLS (httpsToWarpTLSConfig conf) (httpsToWarpConfig conf) app
|
backend app conf = HTTPS.runTLS (httpsToWarpTLSConfig conf) (httpsToWarpConfig conf) app
|
||||||
|
#endif
|
||||||
|
|
17
app/Main.hs
17
app/Main.hs
|
@ -15,23 +15,6 @@ import Control.Concurrent
|
||||||
import Backend.Backend
|
import Backend.Backend
|
||||||
import Options.Applicative
|
import Options.Applicative
|
||||||
|
|
||||||
#ifdef HTTP_SUPPORT
|
|
||||||
import qualified Network.Wai.Handler.Warp as HTTP
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HTTPS_SUPPORT
|
|
||||||
import qualified Network.Wai.Handler.WarpTLS as HTTPS
|
|
||||||
import qualified Network.Wai.Handler.Warp as HTTP
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef FASTCGI_SUPPORT
|
|
||||||
import qualified Network.Wai.Handler.FastCGI as FastCGI
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CGI_SUPPORT
|
|
||||||
import qualified Network.Wai.Handler.CGI as CGI
|
|
||||||
#endif
|
|
||||||
|
|
||||||
-- maybe we should use Control.Concurrent.ParallelIO but right
|
-- maybe we should use Control.Concurrent.ParallelIO but right
|
||||||
-- now we just rely that the backends fork and don't block
|
-- now we just rely that the backends fork and don't block
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
|
|
26
package.yaml
26
package.yaml
|
@ -28,14 +28,6 @@ flags:
|
||||||
description: Build with https support
|
description: Build with https support
|
||||||
manual: true
|
manual: true
|
||||||
default: true
|
default: true
|
||||||
fast-cgi:
|
|
||||||
description: Build with fastcgi support -- this depends on the fcgi c library
|
|
||||||
manual: true
|
|
||||||
default: true
|
|
||||||
cgi:
|
|
||||||
description: Build with cgi support
|
|
||||||
manual: true
|
|
||||||
default: true
|
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
- base >= 4.7 && < 5
|
- base >= 4.7 && < 5
|
||||||
|
@ -62,15 +54,6 @@ when:
|
||||||
dependencies:
|
dependencies:
|
||||||
- warp-tls
|
- warp-tls
|
||||||
- warp
|
- warp
|
||||||
- condition: flag(fast-cgi)
|
|
||||||
dependencies:
|
|
||||||
- wai-handler-fastcgi
|
|
||||||
- condition: flag(cgi)
|
|
||||||
dependencies:
|
|
||||||
wai-extra
|
|
||||||
|
|
||||||
build-tools:
|
|
||||||
- cpphs
|
|
||||||
|
|
||||||
executables:
|
executables:
|
||||||
tickLeisteServer:
|
tickLeisteServer:
|
||||||
|
@ -80,9 +63,6 @@ executables:
|
||||||
- -threaded
|
- -threaded
|
||||||
- -rtsopts
|
- -rtsopts
|
||||||
- -with-rtsopts=-N
|
- -with-rtsopts=-N
|
||||||
- -cpp
|
|
||||||
- -pgmP cpphs
|
|
||||||
- -optP --cpp
|
|
||||||
when:
|
when:
|
||||||
- condition: flag(http)
|
- condition: flag(http)
|
||||||
cpp-options:
|
cpp-options:
|
||||||
|
@ -90,12 +70,6 @@ executables:
|
||||||
- condition: flag(https)
|
- condition: flag(https)
|
||||||
cpp-options:
|
cpp-options:
|
||||||
- -DHTTPS_SUPPORT
|
- -DHTTPS_SUPPORT
|
||||||
- condition: flag(fast-cgi)
|
|
||||||
cpp-options:
|
|
||||||
- -DFASTCGI_SUPPORT
|
|
||||||
- condition: flag(cgi)
|
|
||||||
cpp-options:
|
|
||||||
- -DCGI_SUPPORT
|
|
||||||
|
|
||||||
tests:
|
tests:
|
||||||
tickLeisteServer-test:
|
tickLeisteServer-test:
|
||||||
|
|
|
@ -52,9 +52,7 @@ extra-deps:
|
||||||
flags:
|
flags:
|
||||||
tickLeisteServer:
|
tickLeisteServer:
|
||||||
http: true
|
http: true
|
||||||
https: true
|
https: false
|
||||||
fast-cgi: true
|
|
||||||
cgi: true
|
|
||||||
|
|
||||||
# Extra package databases containing global packages
|
# Extra package databases containing global packages
|
||||||
# extra-package-dbs: []
|
# extra-package-dbs: []
|
||||||
|
|
|
@ -23,16 +23,6 @@ source-repository head
|
||||||
type: git
|
type: git
|
||||||
location: https://github.com/githubuser/tickLeisteServer
|
location: https://github.com/githubuser/tickLeisteServer
|
||||||
|
|
||||||
flag cgi
|
|
||||||
description: Build with cgi support
|
|
||||||
manual: True
|
|
||||||
default: True
|
|
||||||
|
|
||||||
flag fast-cgi
|
|
||||||
description: Build with fastcgi support -- this depends on the fcgi c library
|
|
||||||
manual: True
|
|
||||||
default: True
|
|
||||||
|
|
||||||
flag http
|
flag http
|
||||||
description: Build with http support
|
description: Build with http support
|
||||||
manual: True
|
manual: True
|
||||||
|
@ -47,8 +37,6 @@ executable tickLeisteServer
|
||||||
main-is: Main.hs
|
main-is: Main.hs
|
||||||
other-modules:
|
other-modules:
|
||||||
Backend.Backend
|
Backend.Backend
|
||||||
Backend.CGI
|
|
||||||
Backend.FastCGI
|
|
||||||
Backend.Http
|
Backend.Http
|
||||||
Backend.Https
|
Backend.Https
|
||||||
Config
|
Config
|
||||||
|
@ -57,9 +45,7 @@ executable tickLeisteServer
|
||||||
Paths_tickLeisteServer
|
Paths_tickLeisteServer
|
||||||
hs-source-dirs:
|
hs-source-dirs:
|
||||||
app
|
app
|
||||||
ghc-options: -threaded -rtsopts -with-rtsopts=-N -cpp -pgmP cpphs -optP --cpp
|
ghc-options: -threaded -rtsopts -with-rtsopts=-N
|
||||||
build-tools:
|
|
||||||
cpphs
|
|
||||||
build-depends:
|
build-depends:
|
||||||
aeson
|
aeson
|
||||||
, base >=4.7 && <5
|
, base >=4.7 && <5
|
||||||
|
@ -83,20 +69,10 @@ executable tickLeisteServer
|
||||||
build-depends:
|
build-depends:
|
||||||
warp
|
warp
|
||||||
, warp-tls
|
, warp-tls
|
||||||
if flag(fast-cgi)
|
|
||||||
build-depends:
|
|
||||||
wai-handler-fastcgi
|
|
||||||
if flag(cgi)
|
|
||||||
build-depends:
|
|
||||||
wai-extra
|
|
||||||
if flag(http)
|
if flag(http)
|
||||||
cpp-options: -DHTTP_SUPPORT
|
cpp-options: -DHTTP_SUPPORT
|
||||||
if flag(https)
|
if flag(https)
|
||||||
cpp-options: -DHTTPS_SUPPORT
|
cpp-options: -DHTTPS_SUPPORT
|
||||||
if flag(fast-cgi)
|
|
||||||
cpp-options: -DFASTCGI_SUPPORT
|
|
||||||
if flag(cgi)
|
|
||||||
cpp-options: -DCGI_SUPPORT
|
|
||||||
default-language: Haskell2010
|
default-language: Haskell2010
|
||||||
|
|
||||||
test-suite tickLeisteServer-test
|
test-suite tickLeisteServer-test
|
||||||
|
@ -107,8 +83,6 @@ test-suite tickLeisteServer-test
|
||||||
hs-source-dirs:
|
hs-source-dirs:
|
||||||
test
|
test
|
||||||
ghc-options: -threaded -rtsopts -with-rtsopts=-N
|
ghc-options: -threaded -rtsopts -with-rtsopts=-N
|
||||||
build-tools:
|
|
||||||
cpphs
|
|
||||||
build-depends:
|
build-depends:
|
||||||
aeson
|
aeson
|
||||||
, base >=4.7 && <5
|
, base >=4.7 && <5
|
||||||
|
@ -133,10 +107,4 @@ test-suite tickLeisteServer-test
|
||||||
build-depends:
|
build-depends:
|
||||||
warp
|
warp
|
||||||
, warp-tls
|
, warp-tls
|
||||||
if flag(fast-cgi)
|
|
||||||
build-depends:
|
|
||||||
wai-handler-fastcgi
|
|
||||||
if flag(cgi)
|
|
||||||
build-depends:
|
|
||||||
wai-extra
|
|
||||||
default-language: Haskell2010
|
default-language: Haskell2010
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue