Ability to have raw strings in config
Hello,
I would like to have raw strings in config, with placeholders not replaced.
Syntax, could be whatever...
r'{ my GraphQL request }'
escaping with \ can become cumbersome.
Have you tried to just escape the opening { with \{.
In the documentation for the request_body directive, I have included an example: https://github.com/caddyserver/website/pull/468
In many contexts we only replace "known" placeholders, or placeholders which actually have or could have a value. What is your use case?
I would like to have unmodified body, or a way to load them from a file, for example.
This request is more complicated than you think. It's not just a Caddyfile syntax thing, because all the Caddyfile is, is fancy scripts to transform your config to JSON, which is what Caddy actually runs with. I don't see how we could generally encode all strings as being "raw". It's up to you to provide it escaped. You can run your own script to escape { brackets, you can use import in the Caddyfile to pull the result in from a separate text file.
I will try with import, thanks!
It is complex, although, if this really was needed, I wonder if we could prefix a string with some flag that disables placeholders. Then when replacer.Replace*() is called, if the input has that prefix, it just strips the prefix and returns the string unchanged.