Is there a way to specify root dir by variable?

19 views
Skip to first unread message

Jiří Sedláček

unread,
Sep 25, 2013, 10:31:23 AM9/25/13
to zer...@googlegroups.com
Hi,

I would like the config bellow to work :-) The problem/feature is that $Dir does not get replaced because it is under "root" key. So far I have managed to start several instances of zerogw on single machine using different variables (Port). This might make me generate a separate config file for every zerogw instance. I would like to avoid that.

_Dir: &Dir ./some/dir
_Port: &Port 8000

Server:
  listen:
    - host: 0.0.0.0
      port: $Port

Routing:
  routing: !Suffix ~
  routing-by: !Header Host
  map:
      "*":
        routing: !Prefix ~
        routing-by: !Uri ~
        map:
            "/path*":
              static:
                enabled: yes
                root: $Dir
                restrict-root: no

Cheers
Jiri

Paul Colomiets

unread,
Sep 25, 2013, 6:24:02 PM9/25/13
to zer...@googlegroups.com
Hi Jiri,

On Wed, Sep 25, 2013 at 5:31 PM, Jiří Sedláček
<yirie.se...@gmail.com> wrote:
> Hi,
>
> I would like the config bellow to work :-) The problem/feature is that $Dir
> does not get replaced because it is under "root" key. So far I have managed
> to start several instances of zerogw on single machine using different
> variables (Port). This might make me generate a separate config file for
> every zerogw instance. I would like to avoid that.
>

Unfortunately "$var" substitutions currently work for string and int
types only (And file and dir are separate types in coyaml). However in
your case you may use yamlish "*Dir" that works for any type
(including lists and mappings) with the limitation that you can't
substitute part of the string. If that would not work for you, let me
know, the former issue should be easy to fix (but backwards
compatibility might be a problem)

--
Paul

Jiří Sedláček

unread,
Sep 26, 2013, 4:24:38 AM9/26/13
to zer...@googlegroups.com
Hi Paul,

thanks for the tips. It almost works. *Dir does get substituted but it is not possible to set it from command line ("-D Dir='/cmd/line/path'"). In the example bellow it always puts the "./some/dir" in place of *Dir even though I set it on the command line.

_Dir: &Dir ./some/dir
_Port: &Port 8000

Server:
  listen:
    - host: 0.0.0.0
      port: $Port

Routing:
  routing: !Suffix ~
  routing-by: !Header Host
  map:
      "*":
        routing: !Prefix ~
        routing-by: !Uri ~
        map:
            "/path*":
              static:
                enabled: yes
                root: *Dir
                restrict-root: no

But it is not a big deal. I will just pregenerate the config file right before zerogw execution.

Jiri




--
Paul

--
You received this message because you are subscribed to a topic in the Google Groups "Zerogw" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/zerogw/IbD7gMIiOfU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to zerogw+un...@googlegroups.com.
To post to this group, send email to zer...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/zerogw/CAA0gF6qb4gzr%2ByVWG_CrPEwNYV6F9TpzcF2rJv5ocVtOJPZv1Q%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply all
Reply to author
Forward
0 new messages