summaryrefslogtreecommitdiff
path: root/contrib/cgi/gemini.go
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/cgi/gemini.go')
-rw-r--r--contrib/cgi/gemini.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/contrib/cgi/gemini.go b/contrib/cgi/gemini.go
index d245c8e..1e97939 100644
--- a/contrib/cgi/gemini.go
+++ b/contrib/cgi/gemini.go
@@ -1,12 +1,14 @@
package cgi
import (
+ "bytes"
"context"
"fmt"
"strings"
sr "tildegit.org/tjp/sliderule"
"tildegit.org/tjp/sliderule/gemini"
+ "tildegit.org/tjp/sliderule/logging"
)
// GeminiCGIDirectory runs any executable files relative to a root directory on the file system.
@@ -30,11 +32,17 @@ func GeminiCGIDirectory(pathRoot, fsRoot string) sr.Handler {
return nil
}
- stdout, exitCode, err := RunCGI(ctx, request, filepath, pathinfo)
+ stderr := &bytes.Buffer{}
+ stdout, exitCode, err := RunCGI(ctx, request, filepath, pathinfo, stderr)
if err != nil {
return gemini.Failure(err)
}
if exitCode != 0 {
+ ctx.Value("warnlog").(logging.Logger).Log(
+ "msg", "cgi exited with non-zero exit code",
+ "code", exitCode,
+ "stderr", stderr.String(),
+ )
return gemini.CGIError(fmt.Sprintf("CGI process exited with status %d", exitCode))
}