lejp_conf: pmo as alias for cgi-env

Since cgi-env only applies for cgi types, we can
re-use it for generic per-mount options (pmo)
This commit is contained in:
Andy Green 2016-07-06 07:37:34 +08:00
parent ae0d8d74f9
commit cd6a70672b
2 changed files with 20 additions and 6 deletions

View file

@ -259,7 +259,18 @@ Mount protocols are used to control what kind of translation happens
Other mount options
-------------------
1) When using a cgi:// protcol origin at a mountpoint, you may also give cgi environment variables specific to the mountpoint like this
1) Some protocols may want "per-mount options" in name:value format. You can
provide them using "pmo"
{
"mountpoint": "/stuff",
"origin": "callback://myprotocol",
"pmo": [{
"myname": "myvalue"
}]
}
2) When using a cgi:// protcol origin at a mountpoint, you may also give cgi environment variables specific to the mountpoint like this
```
{
"mountpoint": "/git",
@ -272,11 +283,11 @@ Other mount options
```
This allows you to customize one cgi depending on the mountpoint (and / or vhost).
2) It's also possible to set the cgi timeout (in secs) per cgi:// mount, like this
3) It's also possible to set the cgi timeout (in secs) per cgi:// mount, like this
```
"cgi-timeout": "30"
```
3) `callback://` protocol may be used when defining a mount to associate a
4) `callback://` protocol may be used when defining a mount to associate a
named protocol callback with the URL namespace area. For example
```
{
@ -292,7 +303,7 @@ payload generation inside a plugin.
See the related notes in README.coding.md
4) Cache policy of the files in the mount can also be set. If no
5) Cache policy of the files in the mount can also be set. If no
options are given, the content is marked uncacheable.
```
{
@ -305,7 +316,7 @@ options are given, the content is marked uncacheable.
}
```
4) You can also define a list of additional mimetypes per-mount
6) You can also define a list of additional mimetypes per-mount
```
"extra-mimetypes": {
".zip": "application/zip",

View file

@ -81,6 +81,7 @@ static const char * const paths_vhosts[] = {
"vhosts[].ipv6only",
"vhosts[].ssl-option-set",
"vhosts[].ssl-option-clear",
"vhosts[].mounts[].pmo[].*",
};
enum lejp_vhost_paths {
@ -119,6 +120,7 @@ enum lejp_vhost_paths {
LEJPVP_IPV6ONLY,
LEJPVP_SSL_OPTION_SET,
LEJPVP_SSL_OPTION_CLEAR,
LEJPVP_PMO
};
static const char * const parser_errs[] = {
@ -469,6 +471,7 @@ lejp_vhosts_cb(struct lejp_ctx *ctx, char reason)
case LEJPVP_ECDH_CURVE:
a->info->ecdh_curve = a->p;
break;
case LEJPVP_PMO:
case LEJPVP_CGI_ENV:
mp_cgienv = lwsws_align(a);
a->p += sizeof(*a->m.cgienv);
@ -484,7 +487,7 @@ lejp_vhosts_cb(struct lejp_ctx *ctx, char reason)
a->p += snprintf(a->p, a->end - a->p, "%s", ctx->buf);
*(a->p)++ = '\0';
lwsl_notice(" adding cgi-env '%s' = '%s'\n", mp_cgienv->name,
lwsl_notice(" adding pmo / cgi-env '%s' = '%s'\n", mp_cgienv->name,
mp_cgienv->value);
break;