H2o: Independent element for YAML anchors

Created on 26 Apr 2018  路  5Comments  路  Source: h2o/h2o

related: #741

Reading the docs, I get that I can define an anchor inside some pre-defined element(s), as shown in the issue above:

hosts:
  "example.com":
    listen:
      port: 443
      ssl:
        certificate-file: /path/to/example.com.crt
        key-file:         /path/to/example.com.crt
    paths:  &default_paths
      "/":
        file.dir: /path/to/doc-root
  "example.org":
    listen:
      port: 443
      ssl:
        certificate-file: /path/to/example.org.crt
        key-file:         /path/to/example.org.crt
    paths:  *default_paths

But it gets harder to read when your config file gets bigger. I tried cutting all anchors out:

anchors:
  https_settings: &https
    port: 443
  default_paths:  &default_paths
    "/":
      file.dir: /path/to/doc-root

hosts:
  "example.com":
    listen:
      <<: *https
      ssl:
        certificate-file: /path/to/example.com.crt
        key-file:         /path/to/example.com.crt
    paths:  *default_paths
  "example.org":
    listen:
      <<: *https
      ssl:
        certificate-file: /path/to/example.org.crt
        key-file:         /path/to/example.org.crt
    paths:  *default_paths

without any luck. I get Apr 25 21:47:27 ip-10-0-0-65 h2o[4530]: [/etc/h2o/h2o.conf:1] unknown command: anchors error logs.

Do we already have some predefined namespace (element) to do things like this? If not, I really want to have something like this, where things included in that particular element (anchors) will just be interpolated.

Most helpful comment

I filed https://github.com/h2o/h2o/pull/1739, which adds stash directive.

All 5 comments

yeah, I'm currently doing that, but dividing everything into pieces of files looks very bad to me (partially because relative paths are not recognized in !file). I don't want to jump around little files just for one row :(

I filed https://github.com/h2o/h2o/pull/1739, which adds stash directive.

To write a configuration file you need to learn Rack specs Yaml Ruby than Mruby of course H2o web server.....Of course it is very flexible you can write anything you want but If you learn those additional things otherwise you cannot write anything and H2o wev server will be become useless for you....

I tried the master branch, and seems it works very good! Thanks i110! I'll close this.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Jxck picture Jxck  路  7Comments

taosx picture taosx  路  6Comments

paulpref picture paulpref  路  5Comments

utrenkner picture utrenkner  路  5Comments

ahupowerdns picture ahupowerdns  路  8Comments