summaryrefslogtreecommitdiff
path: root/server/src/net
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2021-08-31 22:57:23 +0100
committerJuan J. Martinez <jjm@usebox.net>2021-08-31 23:04:09 +0100
commita6bd4cba833bd576c20ca05badc3aa26ce7f0f91 (patch)
treefe66763fbc353a8ab435b5dfdb4fedad12a42ce2 /server/src/net
parentc09ffd688c1edd43c545aaf442a1cb582d5ad20d (diff)
downloadspacebeans-a6bd4cba833bd576c20ca05badc3aa26ce7f0f91.tar.gz
spacebeans-a6bd4cba833bd576c20ca05badc3aa26ce7f0f91.zip
Support to pass env variables to CGIs
Env variables are configured per virtual host.
Diffstat (limited to 'server/src/net')
-rw-r--r--server/src/net/usebox/gemini/server/Response.scala5
-rw-r--r--server/src/net/usebox/gemini/server/Server.scala3
-rw-r--r--server/src/net/usebox/gemini/server/ServiceConf.scala3
3 files changed, 7 insertions, 4 deletions
diff --git a/server/src/net/usebox/gemini/server/Response.scala b/server/src/net/usebox/gemini/server/Response.scala
index a6993c4..edb6cdc 100644
--- a/server/src/net/usebox/gemini/server/Response.scala
+++ b/server/src/net/usebox/gemini/server/Response.scala
@@ -91,7 +91,8 @@ case class Cgi(
scriptName: String,
host: String,
port: String,
- remoteAddr: String
+ remoteAddr: String,
+ vhEnv: Map[String, String]
) extends Response {
private[this] val logger = getLogger
@@ -100,7 +101,7 @@ case class Cgi(
val responseRe = "([0-9]{2}) (.*)".r
- val env = Map(
+ val env = vhEnv ++ Map(
"GATEWAY_INTERFACE" -> "CGI/1.1",
"SERVER_SOFTWARE" -> s"${BuildInfo.name}/${BuildInfo.version}",
"SERVER_PROTOCOL" -> "GEMINI",
diff --git a/server/src/net/usebox/gemini/server/Server.scala b/server/src/net/usebox/gemini/server/Server.scala
index 3c78721..f402191 100644
--- a/server/src/net/usebox/gemini/server/Server.scala
+++ b/server/src/net/usebox/gemini/server/Server.scala
@@ -137,7 +137,8 @@ case class Server(conf: ServiceConf) {
scriptName = cgiFile.getFileName().toString(),
host = vhost.host,
port = conf.port.toString(),
- remoteAddr = remoteAddr
+ remoteAddr = remoteAddr,
+ vhEnv = vhost.environment.getOrElse(Map())
)
case path if !path.exists() =>
logger.debug("no resource")
diff --git a/server/src/net/usebox/gemini/server/ServiceConf.scala b/server/src/net/usebox/gemini/server/ServiceConf.scala
index dc28650..43786af 100644
--- a/server/src/net/usebox/gemini/server/ServiceConf.scala
+++ b/server/src/net/usebox/gemini/server/ServiceConf.scala
@@ -26,7 +26,8 @@ case class VirtualHost(
geminiParams: Option[String] = None,
directories: List[Directory] = Nil,
userDirectories: Boolean = false,
- userDirectoryPath: Option[String] = None
+ userDirectoryPath: Option[String] = None,
+ environment: Option[Map[String, String]] = None
)
object VirtualHost {