summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordefanor <defanor@uberspace.net>2019-02-03 22:57:11 +0300
committerdefanor <defanor@uberspace.net>2019-02-03 22:57:11 +0300
commitd032cdc98f1c05306cdab9cff41362db2e6bfa06 (patch)
tree8c82e3169f9b89764549932b6c837e98cd8c5714
parent83a90895a5b6f1267ad272bfe23a6b604068d3c0 (diff)
Replace wai-cli with wai-handler-fastcgi
Another step towards making pgxhtml more lightweight, dependencies-wise.
-rw-r--r--Main.hs4
-rw-r--r--README.md9
-rw-r--r--example/README.md19
-rw-r--r--pgxhtml.cabal2
4 files changed, 25 insertions, 9 deletions
diff --git a/Main.hs b/Main.hs
index e26cac6..48f2d85 100644
--- a/Main.hs
+++ b/Main.hs
@@ -49,7 +49,7 @@ import Data.Text.Encoding (encodeUtf8)
import Network.Wai.Middleware.HttpAuth (extractBasicAuth)
import Network.HTTP.Types.Header (hWWWAuthenticate)
import Network.Wai.Middleware.Timeout (timeout)
-import Network.Wai.Cli (defWaiMain)
+import Network.Wai.Handler.FastCGI (run)
import Control.Monad (join)
import Control.Arrow ((***))
import Control.Exception (bracket, finally, catches, Handler(..))
@@ -250,7 +250,7 @@ main = do
conf <- decodeEnv
case conf of
Left err -> putStrLn err
- Right conf' -> defWaiMain
+ Right conf' -> run
$ timeout (connectionTimeout conf') $ \req respond ->
case ("authorised" `elem` pathInfo req, extractBasicAuth
=<< lookup hAuthorization (requestHeaders req)) of
diff --git a/README.md b/README.md
index 9d4e64a..abb2c0c 100644
--- a/README.md
+++ b/README.md
@@ -16,16 +16,14 @@ Request timeouts are enforced and do cancel DB queries, but otherwise
it relies on PostgreSQL for access permissions and security policies,
as well as for any business logic that may be needed.
-It is based on WAI, and can be used with (S,Fast)CGI, or various other
-methods.
+FastCGI is used.
## Usage
### Invocation
-See [wai-cli](https://hackage.haskell.org/package/wai-cli) for CLI
-arguments. The used environment variables are:
+The used environment variables are:
- `TIMEOUT`: request timeout in seconds, 10 by default.
- `XSLT_DIR`: a directory to read XSLT files from, current working
@@ -92,6 +90,9 @@ pgxhtml only focuses on providing a web interface to a database.
would likely be desired (perhaps granting `CREATE` just to the
database owner/administrators).
+- Possibly web server rules (such as nginx rewrites), if it's desired
+ to strictly limit available queries.
+
## See also
- [PostgREST](http://postgrest.org/), "a standalone web server that
diff --git a/example/README.md b/example/README.md
index b6cfbfa..d70b595 100644
--- a/example/README.md
+++ b/example/README.md
@@ -14,5 +14,20 @@ them.
`list.xsl` includes report and search forms, and lists the bugs.
-To quickly try it, run `pgxhtml --devlogging` in this directory,
-with database connection environment variables set if needed.
+To quickly try it, run `spawn-fcgi -p 5152 /bin/env pgxhtml` in this
+directory, with database connection environment variables set if
+needed, an `127.0.0.1 pgxhtml-test` entry in `/etc/hosts`, and a nginx
+config akin to the following:
+
+```
+server {
+ listen localhost:80;
+ server_name pgxhtml-test;
+
+ location / {
+ include fastcgi_params;
+ fastcgi_param PATH_INFO $fastcgi_script_name;
+ fastcgi_pass 127.0.0.1:5152;
+ }
+}
+```
diff --git a/pgxhtml.cabal b/pgxhtml.cabal
index 78de784..3d8c94b 100644
--- a/pgxhtml.cabal
+++ b/pgxhtml.cabal
@@ -29,8 +29,8 @@ executable pgxhtml
, text >=1.2 && <1.3
, unordered-containers >=0.2 && <0.3
, wai >=3.2 && <3.3
- , wai-cli >=0.1 && <0.2
, wai-extra >=3.0 && <3.1
+ , wai-handler-fastcgi >= 3.0.0.2
, warp >=3.2 && <3.3
default-language: Haskell2010
pkgconfig-depends: libxml-2.0, libxslt, libexslt