MCPcopy
hub / github.com/caddyserver/caddy / openCurlyBrace

Method openCurlyBrace

caddyconfig/caddyfile/parse.go:687–695  ·  view source on GitHub ↗

openCurlyBrace expects the current token to be an opening curly brace. This acts like an assertion because it returns an error if the token is not an opening curly brace. It does NOT advance the token.

()

Source from the content-addressed store, hash-verified

685// because it returns an error if the token is not
686// an opening curly brace. It does NOT advance the token.
687func (p *parser) openCurlyBrace() error {
688 if p.Val() != "{" {
689 if p.valLooksLikeGlobalOptionsAfterImportedSnippets() {
690 return p.Err("global options block must appear before import directives; move the global options block to the top of the Caddyfile")
691 }
692 return p.SyntaxErr("{")
693 }
694 return nil
695}
696
697func (p *parser) valLooksLikeGlobalOptionsAfterImportedSnippets() bool {
698 if p.Val() != "import" || len(p.block.Keys) == 0 {

Callers 2

blockContentsMethod · 0.95
blockTokensMethod · 0.95

Calls 4

ValMethod · 0.80
ErrMethod · 0.80
SyntaxErrMethod · 0.80

Tested by

no test coverage detected